user3629774
user3629774

Reputation: 82

Stylesheet not working in django

I have tried linking a stylesheet to my template in django and it doesnt do anything:

the template(called base.html)

<!DOCTYPE html>
<html>

<head>
<title></title>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}base.css">
</head>
<body>
<h1>Welcome to {{ page }}</h1>
</body>
</html>

This is the settings about the static files:

STATIC_URL = '/static/'
STATICFILES_DIRS = ('C:/Users/GAL/PycharmProjects/sqvatPreAlpha/static/',)

The way my project is built:

https://i.sstatic.net/Ldndl.png

What should I do to make it work?

Upvotes: 1

Views: 448

Answers (2)

tatlar
tatlar

Reputation: 3176

You haven't mentioned if this is a dev or production box. If the latter, make sure you run:

python manage.py collectstatic

This will collect all your static files that you have in the Django project root, and copy them to the STATIC_URL directory. If you are still running into problems after trying this, you most likely have something incorrectly defined in your settings file.

Upvotes: 1

aldo_vw
aldo_vw

Reputation: 638

You have to add {% load staticfiles %} at the beginning of base.html Also, it seems you need to add .cssto your css file.

Upvotes: 0

Related Questions