django - Where to put templates and static assets for deployment -
where should put static assets deployment? have in 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 directory structure on local machine:
├── env ├── src | ├── esp_project | ├── reports | └── templates | ├── registration | └── reports └── static └── static └── css ├── js └── img
from docs understand should served apache2, not python. clarify this? , templates, in "right" place?
for templates can make new folder in main static directory.
in settings.py can set path this.
template_dirs = ( os.path.join(os.path.dirname(__file__), 'static', 'templates'), )
you can add in template loaders settings.py.
template_loaders = ( 'django.template.loaders.filesystem.loader', 'django.template.loaders.app_directories.loader', )
now django in static/static/templates
templates (which static files).
the rest looks make sure have static_url = '/static/'
above if debug:
Comments
Post a Comment