A modern Django project is a collection of apps. Files are looked up under 
conventional paths within apps. Modules (especially the settings module) can 
live anywhere on $PYTHONPATH. Actually, there's not such thing as a project 
root.

For instance, instead of using TEMPLATE_DIRS, project-wide templates can go 
into an "myproject" application. You need one anyway as soon as you write a 
custom template tag or filter.

There are two special cases that don't fit into apps: STATIC_ROOT and 
MEDIA_ROOT. (Technically, there's ALLOWED_INCLUDE_ROOTS too, but it isn't 
commonly used.)

Static files are collected from the apps into STATIC_ROOT that is then served 
by the web server. To avoid accidentally leaking Python code over the web, it's 
a good idea to keep this directory outside of your source tree.

Media files are written by the application server into MEDIA_ROOT. It's a good 
idea to put them on a separate partition (DoS by filling up / isn't fun), or at 
least in a directory outside of your source tree, which must be read-only for 
the web server.

For local development, it's certainly fine to store the code in 
/home/myproject, compile the static files in /home/myproject/static, and 
uploading the media files in /home/myproject/media, and it's convenient to 
express that with relative paths. But it's hardly a best practice in production 
— at least, not until you've spent 30 seconds thinking about it.

Django leaves it up to the developer to structure the settings for different 
environments. This means we cannot provide a "development only" settings 
template.

For these reasons, I'm against codifying PROJECT_ROOT and relative paths in 
Django's default settings files. No amount of "+1 because I'm doing it already" 
or blog posts will make it a best practice in production.

And developers will keep doing it until sysadmins tell them not to.

-- 
Aymeric.



-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to