How to set relative url for a css file in Django


Tags: python,css,django

Problem :

enter image description here

My django project is pictured above:

I'm trying to set a path to my css using:

<link href="{% static "css/bootstrap.min.css" %} rel="stylesheet">

In my settings.py I have:

STATIC_URL = '/static/'

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR,  'templates'),

When I run the project I get:

TemplateSyntaxError at /index/

Invalid block tag: 'static'

What am I doing wrong?



Solution :

The problem maybe is: You don't loaded tag for staticfiles.

{% load staticfiles %}

You should load staticfiles first, and then you can use static tag.


    CSS Howto..

    How can i put two divs and one nav into the header at the top-left, top-center and top- right with css

    How to assign css for prettify(syntax highlighter)

    CSS: How to force objects to stay inside container but allow full width background? [duplicate]

    How to get the image height of an image to set another div height

    How to apply CSS locally on any online page?

    How to show an arrow down symbol with CSS

    How to set ASP dropdownlist to read only with css or javascript?

    How to use cookies to change css ?

    How to center text inside a div element? [duplicate]

    How do I apply properties to a previous sibling on hover?

    How do I centre align two BTN button within a jumbotron in HTML

    How to vertically center text overlapping an image?

    How to overflow in CSS/HTML? [closed]

    How to make float : left work same as table-cell?

    how to switch between left and right css rules using Jquery?

    Show content only in printing page not in browser page using CSS or javascript

    How to tell what is the right css line to apply in nested classes

    how to apply css on dynamic loaded html content (jquery mobile+backbone+phonegap)

    How to markup an obscure data table layout for screen readers?

    How to achieve Expand collapse Side Nav with icon using jquery and boostrap css

    How do I do rounded corners in CSS in Google Chrome

    How to make IE respect max AND min-width [duplicate]

    How do I center all my elements?

    How do I align two non-fixed width divs in the center of the browser screen?

    How to make tabs with pure HTML/CSS

    How to add css styles on aria-hidden attribute

    CSS - How to center Absolute Position div with max width in IE9,10,11

    How do you indent subsequent lines of text using

    How to do :hover on circle navigation from angle x to y

    how to override the placeholder icons în AEM 6?