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

Sion Silyn Roberts
Sion Silyn Roberts
498 Points

Challenge. How to resolve "Bummer!"

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

What is wrong with this? {% load static from staticfiles %}

{% extends 'base.html' %}

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

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

I also tried:- <link rel="stylesheet" type="text/css" href="{% static 'css/layout.css' %}" />

articles/templates/articles/article_list.html
{% load static from staticfiles %}

{% extends 'base.html' %}

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

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

2 Answers

Alexandra Barnett
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexandra Barnett
Front End Web Development Techdegree Graduate 46,473 Points

Hi Sion! The challenge mentions that the css file is called "styles.css" rather than "layout.css":

{% load static from staticfiles %}

{% extends 'base.html' %}

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

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

I hope this helps! :)

Sion Silyn Roberts
Sion Silyn Roberts
498 Points

Many thanks indeed. I'm an idiot; or perhaps a dyslexic programmer that works just like a one armed paper hanger.