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

Michael Ibekie
Michael Ibekie
634 Points

Great! Now create a view named index that returns an HttpResponse with the string "Hello Treehouse".

For this question, here's my code:

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

Can someone please tell me what I'm doing wrong?

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

2 Answers

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Michael.

The view should be named index, not hello_treehouse.

And also, please note that we pass in request here.

After those changes you should be good to go.

Vittorio

Patric Daniel Pförtner
Patric Daniel Pförtner
1,542 Points

Hi Michael,

You are very close to the answer, here is how I did it:

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

Why are you learning Python? Maybe we have the same aims! I am learning it to bring my Start UP www.wolf-gate.com to the next level. Thank´s to Kenneth Love it´s easily possible :)