I use Python 3.5 and Django 1.10 to start the development server:
./manage.py runserver 0.0.0.0:8000
In mine settings.pyI have:
DEBUG = True
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
And a directory appwith a subdirectory staticfor its static files:
proj/
proj/
...
app/
static/
a.txt
...
static/
b.txt
Pretty standard.
However: Django does not serve STATIC_ROOTwhenDEBUG = True . It returns app/static/a.txtfor /static/a.txtin order, but not static/b.txtfor /static/b.txt.
Change settings.pyas follows:
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
Works - but then I have to comment STATIC_ROOT(otherwise Django complains that he may not be in STATICFILES_DIRS).
" ", . static2, django-sass-processor, .sass .css .css STATIC_ROOT (, , ).
, :
NGINX (, ). , .
django-sass-processor .css " ", . static2, STATICFILES_DIRS. , , !
URL- urls.py:
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
, , : , Django , URL-, , , , STATICFILES_DIRS.
DEBUG False if - , django.conf.urls.static.static . , django.views.static.serve, , , , - , .
django-sass-processor , , : , settings.py :
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'sass_processor.finders.CssFinder',
]
( - Django, , , ).
, - , .css , STATIC_ROOT , /static/, . , ( ...) .