IDE: IntelliJ IDEA
OS: Windows 7
When use Run
option in IntelliJ with configured Django server
:
IDE: IntelliJ IDEA OS: Windows 7,用IntelliJ中的Run选项,配置好的Django服务器:
Then this command is executed:
然后执行此命令:
runnerw.exe D:\Kursy\VirtualEnv\env1\Scripts\python.exe D:/Kursy/Django/manage.py runserver 8000
runnerw。exe D:\ Kursy VirtualEnv \ \ env1 \ \ python脚本。exe D:/ Kursy / Django /管理。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.
django.core.exceptions。不完善的配置:请求设置USE_I18N,但是设置没有配置。在访问设置之前,您必须定义环境变量DJANGO_SETTINGS_MODULE或调用settings.configure()。
I can run Django app with Windows CMD
First by starting my Virtual python environment:
我可以通过启动我的虚拟python环境,首先运行Windows CMD的Django应用程序:
D:\Kursy\VirtualEnv\env1\Scripts>activate.bat
Then by navigating to Django app directory:
然后导航到Django app目录:
(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?
一切工作正常。我不想在Windows中设置全局环境变量,所以我理解它应该在运行配置中设置为运行配置,在IntelliJ中的运行选项,对吗?
2 个解决方案
#1
2
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必须有一个值(这是设置模块文件)。这条线应该是这样的:
DJANGO_SETTINGS_MODULE=your_proj.settings;.....
#2
2
@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:
@radev应答适用于特定运行配置的设置。有另外一种方法可以避免在IntelliJ Run中出现的DJANGO_SETTINGS_MODULE错误文件>ProjectStructure…(或者直接按Ctrl+Shift+Alt+s)添加对项目设置的引用。py:
sets value for DJANGO_SETTINGS_MODULE
variable for project in IntelliJ so Run
works with default settings.
为IntelliJ项目中的DJANGO_SETTINGS_MODULE变量设置值,因此运行时使用默认设置。
#1
2
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必须有一个值(这是设置模块文件)。这条线应该是这样的:
DJANGO_SETTINGS_MODULE=your_proj.settings;.....
#2
2
@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:
@radev应答适用于特定运行配置的设置。有另外一种方法可以避免在IntelliJ Run中出现的DJANGO_SETTINGS_MODULE错误文件>ProjectStructure…(或者直接按Ctrl+Shift+Alt+s)添加对项目设置的引用。py:
sets value for DJANGO_SETTINGS_MODULE
variable for project in IntelliJ so Run
works with default settings.
为IntelliJ项目中的DJANGO_SETTINGS_MODULE变量设置值,因此运行时使用默认设置。