[Tutor] HttpResponse error

Serdar Tumgoren zstumgoren at gmail.com
Mon Oct 26 23:05:27 CET 2009

> Exception Type: SyntaxError at /
> Exception Value: ("'return' outside function",
> ('c:\\Users\\Vincent\\Documents\\django_bookmarks\\..\\django_bookmarks\\bookmarks\\views.py',
> 15, None, 'return HttpResponse(output)\n'))

The Error message indicates that you've diagnosed the problem
correctly: It appears that the "return" statement is flushed left
rather than being indented. Try indenting it so and see if that works.

The reason it does not work is explained here:


"return may only occur syntactically nested in a function definition,
not within a nested class definition."

Also, while this is indeed a generic Python syntax issue, the django
forums are typically the best place for help with...well...Django.

You can check those out at:


Good luck!


More information about the Tutor mailing list