python - CSS not working in some pages on Django -
i beginner in python , django , have been struggling following problem:
on localhost:8000/ webiste beautiful , working fine on localhost:8000/invoice/ references not working. css example not work images , javascript do.
i using relative links point out path is.
<script src="{% static "js/jquery.min.js" %}"></script> <script src="{% static "js/skel.min.js" %}"></script> <script src="{% static "js/skel-layers.min.js" %}"></script> <script src="{% static "js/init.js" %}"></script> <noscript> <link rel="stylesheet" href="{% static "css/skel.css" %}"/> <link rel="stylesheet" href="{% static "css/style.css" %}"/> <link rel="stylesheet" href="{% static "css/style-xlarge.css" %}"/> </noscript> <img src="{% static "images/pic07.jpg" %}" alt="" />
settings.py
static_url = '/static/' staticfiles_dirs = ( os.path.join(base_dir, "static/"), )
view.py
def home(request): return render(request, 'principal.html',) def invoice(request): return render(request, 'invoice.html',)
when check page code browser see links being referred http://localhost:8000/invoice/static/css/somecss.css.
invoice.html inside /project/folder/templates/ , .css inside /project/static/css/. invoice.html inside same folder index.html (principal.html) page, working is.
also, links inside website/invoice/ page become website/invoice/link instead of website/link
problem has been resolved removing tag. 404 errors on console due js files referencing other css files, added variable template include url:
<script> var url = "{% static 'css/' %}"; </script>
and inside .js used url.concat('style.css')
Comments
Post a Comment