Reputation: 2699
Where should I put all my static assets for deployment? Currently I have this in my settings.py
if DEBUG:
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "static_only")
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "media")
STATICFILES_DIRS = (
os.path.join(os.path.dirname(BASE_DIR), "static", "static"),
)
Here's my directory structure on my local machine:
├── env
├── src
| ├── esp_project
| ├── reports
| └── templates
| ├── registration
| └── reports
└── static
└── static
└── css
├── js
└── img
From the docs I understand they should be served by apache2, not by python. Could someone clarify this? And what about templates, are those in the "right" place?
Upvotes: 0
Views: 113
Reputation: 69
For your templates you can make a new folder in you main static directory.
In your settings.py you can set the path like this.
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'static', 'templates'),
)
You can also add in template loaders to your settings.py.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
Now Django will look in static/static/templates
for your templates (which are static files).
The rest looks good just make sure you have STATIC_URL = '/static/'
above if Debug:
See: Django Project Loading Templates
Upvotes: 1