Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Django Basics Model Administration First app view

Omprakash Panigrahi
Omprakash Panigrahi
9,632 Points

Task 1 is no longer passing when checking Task 2

I am sure there is something wrong with the function code that I have written. But I am unable to figure it out. Task 1 was passing before but now its not.

articles/views.py
from django.http import HttpResponse

# Write your views here
from .models import Article

def article_list(request):
    total_articles = len(Article.objects.all())
    return HttpResponse("There are %s articles." total_articles )

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing great, but your last line contains a syntax error which is why you're receiving the "Task 1 is no longer passing" message. At this point, your code can no longer be compiled/interpreted thus negating all your previous work.

You're missing a % sign before the variable you are using to place in the token spot.

Alternatively, you could use the .format() function to format your string and pass in the total_articles variable.

  return HttpResponse("There are %s articles." % total_articles )

Alternatively, you could use the %d as total_articles holds a number.

Hope this helps! :sparkles:

Omprakash Panigrahi
Omprakash Panigrahi
9,632 Points

i fixed it! Thanks a lot for your help!