First time here? Check out the FAQ!
1

WingIDE has problems recognizing variables set with django-environ

Hi all, I use django-environ (https://github.com/joke2k/django-environ) on one of my existing Django projects. I developed it outside wing-ide. When I try to import and set up the project in Wing pro 7.2.6 the "secret" variables set in my django-environ file ".env" (see django-environ docs for more information about it) are not recognized. I get the following error message:

 File "/home/didier/Documents/django-project/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 176, in __init__
  raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")

django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

It seems to me that Wing IDE does not recognize the hidden file and can't read the hidden variables. All that said, when I run the project the "classical" way from the command line it works seamlessly.

I use Python 3.8, Django 2.2 and a virtual environment with venv. It runs on Linux Mint 19.2. Has anybody an idea about it?

didierCH's avatar
36
didierCH
asked 2020-11-07 09:40:27 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

Hi folks, I solved the problem. I had to set the DJANGO_SETTINGS_MODULE variable in my projects setting to my development settings. In my case local.py

My settings module looks like this:

├── common.py
├── __init__.py
├── local.py
├── production.py
└── test.py

So I had to set the project settings in my project configuration of wing-ide to the following:

DJANGO_SETTINGS_MODULE=${DJANGO_SITENAME}.config.settings.local
didierCH's avatar
36
didierCH
answered 2020-11-07 10:24:52 -0500
edit flag offensive 0 remove flag delete link

Comments

You might also be able to get Wing to read the .env file by setting Python Executable in Project Properties to Activated Env and specifying that file. However, this assumes that after loading the env 'python' will star the right Python (because that's how virtualenv and conda envs work). I don't know whether or not that assumption would be a problem with django-environ.

Wingware Support's avatar Wingware Support (2020-11-09 08:40:13 -0500) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer