django: ajax view structure
- by zack
I want to know the correct way to structure ajax views in django.
say i do something like :
def foo_json(request):
if is.ajax():
# return JSON here
and make it available as a resource at something like '/foo/data/'..
all is fine..
but if I point the browser at '/foo/data/' .. obviously I get an error (debug) like:
app.views.foo_json didn't return an HttpResponse object.
so... my question is:
Whats the best way structure this kind of view?
..should I return an HTTP response code ..maybe 404 / 405 ... or something else?
- not sure of the best way to handle this, any advice appreciated :)