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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![cj thompson](https://secure.gravatar.com/avatar/1fb2e5f391680a8477d9aac8da1054ac?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
cj thompson
Courses Plus Student 3,456 PointsArticle Detail View, Question 1 of 3.
when I enter this code for the first challenge:
from .models import Step
def article_detail(request, pk): step = get_object_or_404(Step, id=pk, pk=step_pk) return render(request, 'articles/article_detail.html', {'step': step})
I get "Bummer! Did you create the 'article_detail view?" Well, yeah...that's what I was trying t do...
Any help? Thanks.
from django.shortcuts import render
from .models import Article, Writer
from .models import Step
def article_list(request):
articles = Article.objects.all()
return render(request, 'articles/article_list.html', {'articles': articles})
def writer_detail(request, pk):
writer = Writer.objects.get(pk=pk)
return render(request, 'articles/writer_detail.html', {'writer': writer})
def article_detail(request, pk):
step = get_object_or_404(Step, id=pk, pk=step_pk)
return render(request, 'articles/article_detail.html', {'step': step})
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'writer/(?P<pk>\d+)/$', views.writer_detail),
url(r'', views.article_list),
]
3 Answers
![Jennifer Nordell](https://uploads.teamtreehouse.com/production/profile-photos/5432702/micro_jen-square.jpg)
Jennifer Nordell
Treehouse TeacherI think it might be your step import and use of that that's throwing off the challenge. I think you're going above and beyond what they're expecting. Take a look at my solution for step 1.
def article_detail(request, pk):
article = Article.objects.get(pk=pk)
return render(request, 'articles/article_detail.html',{'article': article})
Note: I did not import Step either.
![cj thompson](https://secure.gravatar.com/avatar/1fb2e5f391680a8477d9aac8da1054ac?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
cj thompson
Courses Plus Student 3,456 PointsOK...I just said I should be more patient. But I think I must be missing something really basic for the 3rd question:
def article_detail(request, pk): article = Article.objects.get(pk=pk) article = get_object_or_404(Article, pk=pk) return render(request, 'articles/article_detail.html',{'article': article})
The message says to be sure that bad pk's are returning 404's Seems like this is how he did it in the video...
Thanks again.
![Jennifer Nordell](https://uploads.teamtreehouse.com/production/profile-photos/5432702/micro_jen-square.jpg)
Jennifer Nordell
Treehouse TeacherHonestly? I have no idea LOL. I can't make it past it again either. I can do step one and 2 but fail on step 3. I'd suggest posting a whole new question and let someone with more points/experience than I have answer that one :)
![cj thompson](https://secure.gravatar.com/avatar/1fb2e5f391680a8477d9aac8da1054ac?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
cj thompson
Courses Plus Student 3,456 PointsThanks...I actually think there's a bug. :)
cj thompson
Courses Plus Student 3,456 Pointscj thompson
Courses Plus Student 3,456 PointsThanks...I figured it out right after I posted. Shouldn't be so impatient! Now I'm "stuck" on step 3.
Thanks again for responding so quickly.