From 0b62d4b1416706c2b591e9a322b98892a858088b Mon Sep 17 00:00:00 2001 From: Anand Kumria Date: Thu, 5 Apr 2012 17:37:45 +0100 Subject: [PATCH] Setup locations for media, static files and templates. 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. --- docroot/.placeholder | 0 media/.placeholder | 0 paas/settings/base.py | 7 +++++-- static/.placeholder | 0 static/css/.placeholder | 0 static/img/.placeholder | 0 static/js/.placeholder | 0 templates/.placeholder | 0 templates/email/.placeholder | 0 templates/www/.placeholder | 0 10 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 docroot/.placeholder create mode 100644 media/.placeholder create mode 100644 static/.placeholder create mode 100644 static/css/.placeholder create mode 100644 static/img/.placeholder create mode 100644 static/js/.placeholder create mode 100644 templates/.placeholder create mode 100644 templates/email/.placeholder create mode 100644 templates/www/.placeholder diff --git a/docroot/.placeholder b/docroot/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/media/.placeholder b/media/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/paas/settings/base.py b/paas/settings/base.py index 9923cab..0223a11 100644 --- a/paas/settings/base.py +++ b/paas/settings/base.py @@ -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. @@ -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/" @@ -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 @@ -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 = ( diff --git a/static/.placeholder b/static/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/static/css/.placeholder b/static/css/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/static/img/.placeholder b/static/img/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/static/js/.placeholder b/static/js/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/templates/.placeholder b/templates/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/templates/email/.placeholder b/templates/email/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/templates/www/.placeholder b/templates/www/.placeholder new file mode 100644 index 0000000..e69de29