[Fixed]-Django gives "GET /static/css/style.css HTTP/1.1" 304 0

24👍

An HTTP 304 response means “I don’t need to fetch it again, since it hasn’t changed since I got it last”. So if that’s the response code you got, you may not have a problem at all. Or did you mean 404 (not found)?

In any event, you normally don’t serve static files with Django directly; you do it through your front-end server. On Heroku, they have a special app and setup to help with that. You can read about it at: https://devcenter.heroku.com/articles/django-assets.

Also: you accidentally posted your SECRET_KEY in your message here. Please change that value to something else before you deploy or your site could have a serious security vulnerability. Keep that secret key a secret.

2👍

This could potentially be an issue when you do
{% load static %}
and then {% static 'css/bootstrap.min.css' %}.

When you call {% load static %} it does it for you so you only need to specify the link to the static file you want dropping out the static nested within the href statement.

👤IVI

2👍

I had the same problem with favicon.png, just force browsers to update the cache by adding a GET parameter:

<link rel="shortcut icon" type="image/png" href="{% static 'favicon.png' %}?ver=2"/>
👤SergO

1👍

I have the same problem cuz I use {% load static %} 2-time in base.html and product.html(extent form base.html) so i remove {% load static %} form product.html and i fix problem

Leave a comment