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 trialWilliam Ray Noble
22,190 PointsArticle List Django Challenge
Hello,
The goal is to return a string with the number of articles in the string. I'm not sure why my code isn't working. Any pointers on this would be appreciated!
from django.http import HttpResponse
from .models import Article
def article_list(request):
articles = Article.objects.all()
num = articles.len()
output = "There are {} articles.".format(num)
return HttpResponse(output)
1 Answer
Ave Nurme
20,907 PointsHi William
In Python you need to use len() a bit differently:
num = len(articles)
If you change this line, all should be good. Hope this helps!