Opened 9 years ago

Closed 6 years ago

#11816 closed Cleanup/optimization (duplicate)

defaults in genereated are absolute paths for template directories, media directories and media urls

Reported by: Jacques Mattheij <j@…> 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


'best practice' seems to be to use

import os

OUR_ROOT = os.path.realpath(

MEDIA_ROOT = os.path.join(OUR_ROOT, 'media')

MEDIA_URL = '/media/'

    # 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 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 Changed 9 years ago by Jacques Mattheij <j@…>

two weeks and not out of triage ?

comment:2 Changed 9 years ago by Alex Gaynor

Triage Stage: UnreviewedDesign decision needed

Marking as DDN. It could also be considered a dupe of #694.

comment:3 Changed 7 years ago by Julien Phalip

Severity: Normal
Type: Cleanup/optimization

comment:4 Changed 6 years ago by Aymeric Augustin

Easy pickings: unset
Resolution: duplicate
Status: newclosed
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.

Note: See TracTickets for help on using tickets.
Back to Top