Open juanjoconti opened 5 years ago
If you follow the tutorial exactly, CSS should work fine without adding + staticfiles_urlpatterns()
in blog.css
. (I've just tried it and it works.)
The reason for this is explained in the Django documentation, chapter Managing static files (e.g. images, JavaScript, CSS), section Serving static files during development:
If you use
django.contrib.staticfiles
as explained above [that is: if you have that listed inINSTALLED_APPS
],runserver
will do this [serve the static files] automatically whenDEBUG
is set toTrue
.
When you follow the tutorial, your project will fulfill both these conditions:
In the Your first Django project! section of the tutorial, we use
django-admin.exe startproject mysite .
This generates mysite/settings.py
. As generated, that file already sets DEBUG=True
(and we never change that in the tutorial) and it also sets INSTALLED_APPS
to a list that includes 'django.contrib.staticfiles'
(and we never remove that entry during the tutorial).
I ran into this issue just now because I set DEBUG = False
in settings.py when I was going through the tutorial at some point. I wasn't supposed to do this. I changed it back to false and the CSS loaded fine just as @das-g said
was working thru the tutorial but blog.css wasn't working. I followed juanjoconti's step and blog.css finally worked for me.
Shouldn’t this get closed? Having gone through the tutorial with the intended steps, I can confirm there is no need to + staticfiles_urlpatterns()
.
Custom css from
blog.css
won't load if the urls.py file is not updated as