-
Notifications
You must be signed in to change notification settings - Fork 44
Configure static files
Filip Górczyński edited this page Oct 9, 2015
·
2 revisions
Because of django recommend collecting static files from all appliactions in one directory please follow these steps:
- Add these lines in project.settings module
STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
- in the same file allow all hosts:
ALLOWED_HOSTS = ['*']
- In project.urls module add:
url( r'^static/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': path.join(PROJECT_ROOT, 'static') } ),
to urlpatterns list. PROJECT_ROOT define as:PROJECT_ROOT = path.dirname(path.dirname(__file__))
- Run:
python manage.py collectstatic
- When asked, enter
yes
to overwrite all files within PROJECT/static/ directory. All files from applications static directories should be copied into PROJECT/static/ directory.