Serving static files and media in Django 1.7.1

191 views
Skip to first unread message

Sithembewena Lloyd Dube

unread,
Jan 6, 2015, 6:30:23 PM1/6/15
to django...@googlegroups.com
Hi everyone,

I have a Django 1.7.1 project structured as per documentation. In it, I have an app called "mainsite". In mainsite, I have templates/mainsite/index.html and static/mainsite/bootstrap.css. In the index template, I use {% load staticfiles %} and then for css I have the following link: <link href="{% static "css/bootstrap.css" %}" rel="stylesheet"> However, when I load the page in the browser, the css does not load and when in "view source" mode, I click the link href ("/static/css/bootstrap.css"). This generates a 404 error.

What am I missing? Any suggestions welcome.

P.S: I have the STATIC_URL = '/static/' setting defined in the settings file.

--
Regards,
Sithu Lloyd Dube

Vijay Khemlani

unread,
Jan 6, 2015, 6:35:02 PM1/6/15
to django...@googlegroups.com
the static tag should be 

{% static 'mainsite/bootstrap.css' %}

according to the layout you said

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAH-SnCBJamc9ZKzmy3y63fAo5n7p7xT6G8oAiu%3DFUbjM-KF%2Bbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Sithembewena Lloyd Dube

unread,
Jan 6, 2015, 9:04:04 PM1/6/15
to django...@googlegroups.com
Thanks @Vijay! Can't believe that caught me out like that.

Regards,
Sithu


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages