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 trialMohamed Ashraf
148 PointsI can't solve this quiz
I can't solve this quiz and I don't know where the problem
from django.http import HttpResponse
from .models import Article
# Write your views here
def article_list(request):
Articles= Article.objects.all()
output=join(Articles)
out=len(output)
return HttpResponse("There are" + out + "articles")
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsYou have the correct idea. There are items to clean up:
- There isn't a built-in
join
command. And if there was, it's not necessary since you can get the count (length) of a queryset directly usinglen(Articles.objects.all())
- When concatenating strings, all parts must be strings. So the
out
should be wrapped usingstr(out)
- Punctuation matters! Notice there should be a period at the sentence end and there should be a space before and after the article count value.
Not an syntax error, but it is not a good practice to reuse object names such as Article
as variable names. It can make the code less readable if it's not obvious that Article
no longer represents the imported object Article
. Additionally, you loose access to the imported object Article
once the name is reused locally.
Post back if you need more help. Good luck!!