Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: None  |  size: 1.33 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Serving django static files in development envirnoment
  2. STATIC_URL = '/static/'
  3. STATIC_ROOT = 'C:UsersMaxWorkswwwmysitemysitestatic'
  4. INSTALLED_APPS = (
  5.     'django.contrib.auth',
  6.     'django.contrib.contenttypes',
  7.     'django.contrib.sessions',
  8.     'django.contrib.sites',
  9.     'django.contrib.messages',
  10.     'django.contrib.staticfiles',
  11. )
  12.        
  13. import os
  14.  
  15. DEBUG = True
  16.  
  17. PROJECT_ROOT = os.path.dirname( __file__ )
  18. PROJECT_NAME = os.path.basename(PROJECT_ROOT)
  19.  
  20. STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static/')
  21. STATIC_URL = '/static/'
  22.  
  23. # Additional locations of static files
  24. STATICFILES_DIRS = (
  25.     # Put strings here, like "/home/html/static" or "C:/www/django/static".
  26.     # Always use forward slashes, even on Windows.
  27.     # Don't forget to use absolute paths, not relative paths.
  28.     os.path.join(PROJECT_ROOT, 'web/'),
  29. )
  30.  
  31. # List of finder classes that know how to find static files in
  32. # various locations.
  33. STATICFILES_FINDERS = (
  34.     'django.contrib.staticfiles.finders.FileSystemFinder',
  35.     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  36. )
  37.  
  38.  
  39. TEMPLATE_CONTEXT_PROCESSORS = (
  40.     ...
  41.     'django.core.context_processors.static',
  42.     ...
  43.     ...
  44. )
  45.        
  46. from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  47.  
  48. # ... the rest of your URLconf here ...
  49.  
  50. urlpatterns += staticfiles_urlpatterns()
  51.        
  52. python manage.py collectstatic