'After Mac OS update Pycharm django python console doesn't have right environmental variable but the "run server" works fine

I am using pycharm as editor of my django app. Everything was working fine until I updated my mac os. After that a lot of settings got messed up for the python interpreter.

I managed to fix most of the issue and now I can "run the server" correctly. However, I still can't get the python console to run properly.

When I open the console and I try to import a model, I get the following error:

django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

The thing that kills me is that I have the DJANGO_SETTINGS_MODULE set in my django server environmental variables so it's if the python console was not picking that up.

enter image description here



Solution 1:[1]

Yeah this is a bit of a pain, I suggest checking out the below settings and updating the options for both your settings file AS WELL as your manage.py file and make sure your manage.py file is pointing to your settings.

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mywebsite.settings")

https://www.jetbrains.com/help/pycharm/django-support.html#4902d6de

https://www.jetbrains.com/help/pycharm/console-django-console.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Artisan