Reputation: 24972
IDE: IntelliJ IDEA
OS: Windows 7
When use Run
option in IntelliJ with configured Django server
:
Then this command is executed:
runnerw.exe D:\Kursy\VirtualEnv\env1\Scripts\python.exe D:/Kursy/Django/manage.py runserver 8000
And I getting error:
django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I can run Django app with Windows CMD
First by starting my Virtual python environment:
D:\Kursy\VirtualEnv\env1\Scripts>activate.bat
Then by navigating to Django app directory:
(env1) D:\Kursy\VirtualEnv\env1\Scripts>cd D:\Kursy\Django
(env1) D:\Kursy\Django>python manage.py runserver
Validating models...
0 errors found
May 11, 2014 - 16:25:06
Django version 1.6.4, using settings 'first_django.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Everything works fine.
I don't want to set global enviroment variable in Windows so I understand that it should be set in Run Configuratuion
for Run
option in IntelliJ - am I right?
Upvotes: 1
Views: 3392
Reputation: 24972
@radev answer works for settings for specific Run Configuration
.
There is alternative way to avoid DJANGO_SETTINGS_MODULE
error in IntelliJ Run
Going to File
>ProjectStructure...
(or just Ctrl+Shift+Alt+s) and adding reference to project settings.py
here:
sets value for DJANGO_SETTINGS_MODULE
variable for project in IntelliJ so Run
works with default settings.
Upvotes: 2
Reputation: 891
Yes you're right, but you're missing that DJANGO_SETTINGS_MODULE must have a value (which is the settings module file. the line should look like this:
DJANGO_SETTINGS_MODULE=your_proj.settings;.....
Upvotes: 2