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

Python Django Basics Model Administration First app view

Georgi Koemdzhiev
Georgi Koemdzhiev
12,610 Points

Why this is not passing?

I am cannot figure out why my code for this challenge is not passing. Any ideas, please?

articles/views.py
from django.http import HttpResponse

from . models import Article

# Write your views here

def article_list():
    articles = Article.objects.all()
    num_objects = len(articles)
    output = "There are {} articles".format(num_objects)
    return HttpResponse(output)

1 Answer

Mohammad Usman
Mohammad Usman
5,969 Points

You've made a simple mistake. Your function called article_list needs to have a perimeter. Most Django developers just call it 'request' as this is exactly what the function is doing; it's taking a request and giving you an output. So you should have defined the function as ''' def article_list(request): ... '''

The rest is perfect

Georgi Koemdzhiev
Georgi Koemdzhiev
12,610 Points

Hey! Thank you for your answer! I was able to 'pass' the challenge. And, yes, I did forget that. Thanks again! :)