I launched the small Polls app from Django tutorial here: https://docs.djangoproject.com/en/4.1/intro/tutorial06/
The first time i wrote it, all worked fine. Then I tried to add the same style to all other html files in the same dir as index.html: results.hmtl, votes.html and detail.html and then the strangest thing happened. No styles were added to these files also when i tried to change the style of polls/static/polls/style.css
, nothing happened. I even renamed the style.css and the styles added to index.html remained unchanged. This means django looks for styles elsewhere. So where is this place?
My settings are standard:
settings.py:
STATIC_URL = 'static/'
STATIC_ROOT = ""
index.html:
{% load static %}
<link rel="stylesheet" href="{% static 'polls/style.css' %}">
urls.py:
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('polls/', include('polls.urls')),
path('', include('polls.urls')),
path('admin/', admin.site.urls)
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
No effect whatsoeveer. I read the documentation, read comments here, nothing flashes, so I'm asking here, hoping for a chance to repair my static. Thanks!
Update: The problem was my browser cache - I deleted it and everything is fine now. But this was a helpful lesson - I learned what paths does Django use, how to set and use them and that it does not keep cache by default.