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 trialOmprakash Panigrahi
9,632 PointsTask 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.
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
Treehouse TeacherHi 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!
Omprakash Panigrahi
9,632 Pointsi fixed it! Thanks a lot for your help!