Skip to content

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:

  1. 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'),)
  2. in the same file allow all hosts: ALLOWED_HOSTS = ['*']
  3. 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__))
  4. Run: python manage.py collectstatic
  5. 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.
Clone this wiki locally