#20109: django-admin.py does not correctly set DJANGO_SETTINGS_MODULE (patch
attached)
-------------------------------------+-------------------------------------
Reporter: jamercee | Owner: nobody
Type: New feature | Status: closed
Component: Core (Management | Version: 1.5
commands) | Resolution:
Severity: Normal | worksforme
Keywords: djang-admin.py, | Triage Stage:
manage.py, | Unreviewed
"DJANGO_SETTINGS_MODULE" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Comment (by jamercee):
I should have been more specific in my comment. I did not mean to imply
the location path was not added to sys.path. I was trying to suggest that
unless you run ./manage.py from within the project folder -- it cannot
find the command extensions (only the stock extensions).
If you examine the code, you'll notice it is not adding the path of the
script -- but the parent path.
The default manage.py set's the DJANGO_SETTINGS_MODULE to a path that
includes the project name:
{{{
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name
}}.settings")
}}}
This means the caller needs to set the path to include the parent folder
BEFORE invoking ./manage.py. The mod we propose would do this by default
and save the caller/user from having to do this for themselves (or to
always modifying their manage.py by hand after creating a new project).
Regarding using inspect() rather than __file__. We've developed this
particular recipe over several years to account for the various platform
differences within python (windows, vs. unix vs virtualenv, fronzen
binaries, etc...). There's some discussion of these issues over at
stackoverflow
http://stackoverflow.com/questions/50499/in-python-how-do-i-get-the-path-
and-name-of-the-file-that-is-currently-executin
http://stackoverflow.com/questions/247770/retrieving-python-module-path
http://stackoverflow.com/questions/10293808/how-to-get-the-path-of-the-
executing-frozen-script
I'll admit the solution "might" be overkill -- but in my experience it
works reliably on every platform (even if it's a bit verbose).
--
Ticket URL: <https://code.djangoproject.com/ticket/20109#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.