Lechucico
Lechucico

Reputation: 2112

Django static import on template

I'm trying to import a css file on my template.

Here is the hierachy:

-mega_series
   -mega_series
   -series
      -models.py
      -static
         -series
            -css
               -style.css
      ...
   -manage.py
   -media
      -covers
   -static

Here is how I import it:

{% load static %}
<link rel="stylesheet" type="text/css" src="{% static "series/css/style.css" %}"/>

In settings.py I have it:

STATIC_URL = '/static/'

Why isn't the css loaded?

Upvotes: 0

Views: 1004

Answers (2)

Keerthana Prabhakaran
Keerthana Prabhakaran

Reputation: 3787

Hope this helps! :)

{% load static %}
<link rel="stylesheet" href="{% get_static_prefix %}series/css/style.css" />

in settings.py

BASE_DIR ='%s'%(path_to_mega_series)
STATIC_URL = '/static/'

and your STATIC_ROOT

Upvotes: 0

frfahim
frfahim

Reputation: 525

Import will be like that:

{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static "series/css/style.css" %}"/>

Upvotes: 1

Related Questions