Ankhbayar Bayarsaikhan Ankhbayar Bayarsaikhan - 3 years ago 73
Python Question

Django URL trails other file URLs

I'm building a website on Django. Here is the problem :

url.py :
url(r'^product/(?P<slug>[-_\w]+)/$', ProductView.as_view(), name='product'),


This URL calls product/product-slug successfully, but it affects other files'
urls. Error message is :

"GET /product/lenovo-tv/static/css/bootstrap.min.css HTTP/1.1" 404 4862


What am I missing?
base.html :

<link href="static/css/bootstrap.min.css" rel="stylesheet"/>
<link href="static/css/font-awesome.min.css" rel="stylesheet">
<link href="static/css/custom-styles.css" rel="stylesheet">

Answer Source
{% load static %}
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet"/>
<link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet">
<link href="{% static 'css/custom-styles.css' %}" rel="stylesheet">

in your html use the static files like this for css and js

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download