Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm: DJANGO_SETTINGS_MODULE is undefined

I am using PyCharm IDE and when I run any file.py I get this error:

..raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE) ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

How to configure DJANGO_SETTINGS_MODULE environment variable in PyCharm?

like image 693
user707711 Avatar asked May 13 '11 07:05

user707711


2 Answers

I had the same problem. The settings of my django support was empty:

PyCharm project config

like image 133
Gustavo Ambrozio Avatar answered Sep 23 '22 03:09

Gustavo Ambrozio


I had the same problem as well, and the fix in IntelliJ IDEA is not obvious (especially since there is no notification with a "fix-it" link for this problem).

You'll find you need to set Settings to your Django project's settings.py file in Project Structure > Modules > [your Django project's name] > Django.

Now you know where to stick it.

like image 24
Will Avatar answered Sep 24 '22 03:09

Will