[Answer]-Django local site setup not working with styles.css and a .png file

1πŸ‘

βœ…

I think you just forget to add this line to get the static files :

<!DOCTYPE html>
{% load staticfiles %}

You are using the development server (manage.py runserver) with DEBUG = True while having this problem, right?

Because with DEBUG = False or in production environment, the static files should be served by your server, or a CDN, or another server : https://docs.djangoproject.com/en/1.6/howto/static-files/deployment/

If none of this is working, check that your static folder is located where it’s supposed to : https://docs.djangoproject.com/en/1.6/howto/static-files/ (Configure properly the STATIC_ROOT and django.contrib.staticfiles in INSTALLED_APPS or add a static pattern in your ulrpatterns like described in the doc at the link I provided)

0πŸ‘

Firstly, {% load staticfiles %} should 1st string.

#example.html
{% load staticfiles %}
.....

and collect all staticfiles in project path(where manage.py):

python manage.py collectstatic
πŸ‘€makketagg

Leave a comment