How can I permanently set the environmental variable DJANGO_SETTINGS_MODULE
on WINDOWS
on a permanent basis and be done with it?
I mean
Win Button
+ Pause/Break Button
- This leads to
Control PanelSystem and SecuritySystem
- Click
Advanced System Settings
- Click
Environment Variables
- There are two boxes the first is titled
User variables
and the second System variables
- On the
System variables
click the New Button
- For variable name put in
DJANGO_IMPORT_SETTINGS
XXX--> WHAT DO I PUT IN VARIABLE VALUE TO SET IT ONCE AND FOR ALL?
In the Django Site on this issue it states:
DJANGO_SETTINGS_MODULE
When you use Django, you have to tell it which settings you’re using. Do this by using an environment variable, DJANGO_SETTINGS_MODULE.
The value of DJANGO_SETTINGS_MODULE should be in Python path syntax,e.g. mysite.settings. Note that the settings module should be on the Python import search path.
What does it mean ...should be in Python path syntax e.g. mysite.settings... ?
- I have a certain directory where my
Python
is located:
C:Python27
- I have a certain directory where my
Django
is located: C:Python27Libsite-packagesdjango
What does this mysite
means. What directory is it meanning C:Something......
Can you put this variable once and for all or you have to constantly change it for every project (I hope not!)
And what does this suspiciously line means Note that the settings module should be on the Python import search path.
All I want it to set the DJANGO_SETTINGS_MODULE environmental variable and be done once and for all from this hassle
EDIT
In order to work, Django just has to be pointed at a valid settings file, and by default it
looks for an environment variable named DJANGO_SETTINGS_MODULE to tell it where to find the
settings. The value of this variable should be the Python import path of the settings file, such
as cms.settings.
--> What king of directory is this: cms.settings
? In windows every directory starts with a hard drive as C:Something...... How can you start a directory like this in Windows?
EDIT_2
Excerpt from a book
PROBLEM
Environment variable DJANGO_SETTINGS_MODULE is undefined.
SOLUTION
Run the command python manage.py shell
rather than python
.
MY QUESTION --> ON WHAT DIRECTORY?///CAN YOU SET IT FOR ONCE OR IS IT DIFFERENT PER PROJECT?
MY PROJECT IS STRUCTURED LIKE THIS
C:Python27pysec-master(file)
|__local_settings.py
|__manage.py
|__settings.py
|__C:Python27pysec(file)
|__ __init__.py
|__example.py
|__models.py
|__xbrl.py
|__xbrl_fundamentals.py
I am trying to run models.py
and I have a settings.py
in the C:Python27pysec-master
You can find an exact copy here.
MAYBE_IMPORTANT_EDIT
I have a file called manage.py
in my project which has these contents
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
Does this has to do anything on setting the variable? Do I need to set here here inside the loop?
EDIT
For the command in the IDLE from django.db import settings
do i need to set a directory for the PYTHON_MODULE_SETTINGS
like C:Python27Libsite-packagesdjangodb
?
See Question&Answers more detail:
os