[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:

http://docs.python.org/reference/simple_stmts.html#the-return-statement

"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:

http://groups-beta.google.com/group/django-users?pli=1


Good luck!

Serdar


More information about the Tutor mailing list