Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics Django Templates Static tag

Now that we have the tag available, we can use it in our <link> tag. Use {% static %} to reference the "css/styles

HELP!

articles/templates/articles/article_list.html
{% extends 'base.html' %}
{% load static from staticfiles %}
{% block static %}
<link rel="stylesheet" href="{% static 'css/style.css' %}">
{% endblock %}

{% block content %}
{% for article in articles %}
{{ article.headline }}
{% endfor %}
{% endblock %}

9 Answers

@Aurélien Debord

Try making 'css/styles.css' its been a whie but I think thats what ended up working for this project. For some reason the style sheet is plural??

Try this:

<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}>

{% %} is when you want to execute Python code, {{ }} is when you want to use a Python variable.

Nop:/ it is still giving me "Didn't find the correct {% static %} tag."

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

url_for is a Flask macro, not a Django template tag.

Kenneth Love whats the deal here? the grader doesn't seem to accept the correct answer. I thought I copied exactly what the video taught.

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

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Double check the instructions for the stylesheet's filename.

apparently I misspelled it here but in my code it was correct, but still not passing.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

I just passed it this morning with your code, the correct filename, and importing the static tag. I'm not sure what could be going wrong outside of those things.

It's says Use {% static %} to reference the "css/styles.css" file in the href attribute of the <link> tag. What are we missing?

Kenneth Love
Kenneth Love
Treehouse Guest Teacher
<link rel="stylesheet" href="{% static 'css/style.css' %}">
                                                 ^

@Kenneth Love thats exactly what I entered, three different times, I even skipped this section and Its spelled out exactly the same as your saying and I'm typing, later on in the course.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

The instructions say to link styles.css (as in more than one style), not style.css. You misspelled the filename.

That's really weird! Spent the day brewing today, I'll take a look again tomorrow, but I tried it both ways several times yesterday and with much Aggravation ito my worked as I explained above.

Hello everybody,

I try this and it does not work. Can you tell me what is wrong ?

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

SOLVED

<link rel="stylesheet" href="{% static 'css/styles.css' %}"> -- doesn't work but the grader will accept <link rel="stylesheet" href="{% static "css/styles.css" %}"> for some reason

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

I've tested both <link rel="stylesheet" href="{% static 'css/styles.css' %}"> and <link rel="stylesheet" href="{% static "css/styles.css" %}"> and they both pass. Even <link rel="stylesheet" href="{%static'css/styles.css'%}"> is passing.

this is the correct answer rel="stylesheet" href="{% static "css/styles.css" %}"> other answers doesnt work for exp <link rel="stylesheet" href="{% static 'css/styles.css' %}">