Skip to content

Commit

Permalink
Setup locations for media, static files and templates.
Browse files Browse the repository at this point in the history
We create a resonable hierarchy for both static and templates.

For static files, put them into separate directories by type of object.

This means things can easily be extended to include pdfs, files, etc.

For templates categorise them where they are likely to be used.
This may have issues with 'pdf' and 'csv' templates which can end up
being used in both email and web views. But those are not as common.

We have 'templates/www' prioritise first so that Django will look for
403, 404 and 500 templates there first. Otherwise they will need to be
in the root ('templates') folder.

Finally, we use 'docroot' as the place to collect all static files into.

'docroot' is useful in the local and self-deployment cases. When
deploying to PaaS providers it is something you will want to
re-consider.
  • Loading branch information
akumria committed Apr 6, 2012
1 parent 63587d6 commit 0b62d4b
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 2 deletions.
Empty file added docroot/.placeholder
Empty file.
Empty file added media/.placeholder
Empty file.
7 changes: 5 additions & 2 deletions paas/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
Expand All @@ -62,7 +62,7 @@
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
STATIC_ROOT = os.path.join(PROJECT_DIR, 'docroot')

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
Expand All @@ -73,6 +73,7 @@
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_DIR, 'static'),
)

# List of finder classes that know how to find static files in
Expand Down Expand Up @@ -121,6 +122,8 @@
# 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(PROJECT_DIR, 'templates', 'www',),
os.path.join(PROJECT_DIR, 'templates',),
)

INSTALLED_APPS = (
Expand Down
Empty file added static/.placeholder
Empty file.
Empty file added static/css/.placeholder
Empty file.
Empty file added static/img/.placeholder
Empty file.
Empty file added static/js/.placeholder
Empty file.
Empty file added templates/.placeholder
Empty file.
Empty file added templates/email/.placeholder
Empty file.
Empty file added templates/www/.placeholder
Empty file.

0 comments on commit 0b62d4b

Please sign in to comment.