Ritu Singh
Problem:
I have an issue getting python-decouple to work in my Django project.
My .env file located in what BASE_DIR in settings.py resolves to:
My settings.py:
If I start my django project with the config.encoding line commented out, it errors out with:
If I start my project with that line, different error:
I've added the .env file in pretty much every path available now, no luck :( I've also tried to work with a settings.ini file instead:
This errors out with:
While if I rename the settings.ini file into settings.old, error changes into SECRET_KEY not found. In other words, python-decouple can find the .env and settings.ini files but cannot read them for some reason. Please help :-)
I've also tried creating a fresh venv with just django installed + python-decouple -> same issues. I feel I am missing something very obvious .. but what?
Solution:
To anyone struggling with the same issue, the answer is weird encoding of the .env file. I created this file in powershell (echo . > .env) which set encoding to something weird. Set encoding to UTF-8 or simply create the file in your editor instead, should fix the above.
Answered by: >daan
Credit: >Stackoverflow
Suggested reads:
>How to get item details of Woo Commerce in custom email content?
>How to install Laravel using composer and configure?
>How to make a single result from a database using MySQL?
>How to Make New Model/Controller/Migration in Laravel?
>How to make non-programmers to run a Python program?
>How to solve problems with Python syntax while writing a calculator app?-Python
>How to solve the encoding issue when writing to a text file, with Python?