Opened 6 years ago

Closed 4 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 6 years ago by Jacques Mattheij <j@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

two weeks and not out of triage ?

comment:2 Changed 6 years ago by Alex

  • Triage Stage changed from Unreviewed to Design decision needed

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

comment:3 Changed 5 years ago by julien

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:4 Changed 4 years ago by aaugustin

  • Easy pickings unset
  • Resolution set to duplicate
  • Status changed from new to 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.

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