Opened 15 years ago
Closed 13 years ago
#11816 closed Cleanup/optimization (duplicate)
defaults in genereated settings.py are absolute paths for template directories, media directories and media urls
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
'best practice' seems to be to use
import os OUR_ROOT = os.path.realpath( os.path.dirname(__file__) ) MEDIA_ROOT = os.path.join(OUR_ROOT, 'media') MEDIA_URL = '/media/' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. os.path.join(OUR_ROOT, 'templates') )
Shouldn't the automatically generated settings.py file include these things right from the beginning ?
It can take a newbie like me a long time to figure out all these little details required to make a project relocatable.
Change History (4)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
Marking as DDN. It could also be considered a dupe of #694.
comment:3 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Cleanup/optimization |
comment:4 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
UI/UX: | unset |
This is a duplicate of #16504 which was closed as wontfix.
I have mixed feelings about this idea.
While it would make the initial setup of a new project slightly faster and more-beginner friendly, I really, really don't want people to store uploaded data (media files) next to code in production. This is prone to awful misconfigurations — from making the Python code writable by the webserver to serving uninterpreted Python files from the web root, and probably several others.
Since we can't guess what a good location would be (maybe /var/www/media
, /var/www/{{ projectname }}/media
, D:\\media
, ...), the default is empty.
two weeks and not out of triage ?