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 What a View! HttpResponse

Mona Jalal
Mona Jalal
4,302 Points

bummer

from django.http import HttpResponse def index(): return HttpResponse('Hellow Treehouse')

why is it wrong?

newspaper/views.py
from django.http import HttpResponse
def index():
    return HttpResponse('Hellow Treehouse')

2 Answers

Russell Sawyer
seal-mask
.a{fill-rule:evenodd;}techdegree
Russell Sawyer
Front End Web Development Techdegree Student 15,705 Points

You are very close. I watched the video just before this challenge and Kenneth put in a request variable in the view that comes from the Http library. Also, you have a spelling mistake, with a w in 'hello'

This passed the challenge.

from django.http import HttpResponse

def index(request):
    return HttpResponse('Hello Treehouse')
Mona Jalal
Mona Jalal
4,302 Points

I mean why should we have a request as an argument?

Ricky Catron
Ricky Catron
13,023 Points

request is an argument because that is the browsers request to the server and contains tons of information you will need in your views. It contains the logged in user, the request method (POST or GET, ect), and tons more. You will need all this information and django passes that argument. If your function doesn't accept it django gets an error back saying, well I tried to give you all this information but you didn't accept it.