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 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.