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 Class-based Views Classy Views ListView and DetailView

"List and Detail" challenge - Django Class-based View Course

I am having trouble in the "list and detail" challenge, the error message I am getting is "Bummer! Hmm, didn't get the right view for the Article List URL".

My urls.py looks like this

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^/$', views.ArticleList.as_view(), name="list"),
    url(r'^(?P<pk>\d+)/$', views.ArticleDetail.as_view(), name="detail"),
]

My views.py looks like this:

from django.views.generic import ListView, DetailView

from . import models


class ArticleList(ListView):
    model = models.Article


class ArticleDetail(DetailView):
    model = models.Article

The article_list.html template looks like this:

<h1>Articles</h1>

<ul>
  {% for article in article_list %}
  <li>{{ article.title }}</li>
  {% endfor%
</ul>

And the article_detail.htm template looks like this:

<h1>Article title</h1>
<p>By: {{ article.author }}</p>

{{ article.body|linebreaks }}

Is there an error that I am not seeing or is there something wrong with the code checking on this challenge?

Thanks!

1 Answer

Tatiana Vasilevskaya
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tatiana Vasilevskaya
Python Web Development Techdegree Graduate 28,600 Points

In article_list.html you forgot the closing curly brace in {% endfor %}, in article_detail.htm you should change <h1>Article title</h1> to <h1>{{ article.title }}</h1>

The first one was a typo which I had correct the first time.

But I totally didn't think to make:

<h1>Article title</h1>

become:

<h1>{{ article.title }}</h1>