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 Final Details URL tag In list template

Url tag task 1

what am i doing wrong? i keep getting an error message.

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

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

{% block content %}
{% for article in articles %}
<a href="{% url'articles:detail'pk=article.pk %}">{{ article.headline }}</a>
{% endfor %}
{% endblock %}

1 Answer

Hi Emily

You have a few errors here <a href="{% url'articles:detail'pk=article.pk %}">{{ article.headline }}</a>.

  • missing a space after the word 'url'
  • it is 'articles_detail' and not 'articles:detail'
  • missing another space after 'detail'

Here's the correct version:

{% extends 'base.html' %}
{% load static from staticfiles %}

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

{% block content %}
{% for article in articles %}
  <a href="{% url 'articles_detail' pk=article.pk %}">{{ article.headline }}</a>
{% endfor %}
{% endblock %}

Hope this helps!