Add json_response()
convenience method for all views
er, class-based views anyway
This commit is contained in:
parent
e06f8c16df
commit
e5472a6fae
|
@ -111,6 +111,13 @@ class View(object):
|
|||
kwargs.setdefault('can_cancel', True)
|
||||
return render_to_response(template, kwargs, request=self.request)
|
||||
|
||||
def json_response(self, data):
|
||||
"""
|
||||
Convenience method to return a JSON response.
|
||||
"""
|
||||
return render_to_response('json', data,
|
||||
request=self.request)
|
||||
|
||||
def file_response(self, path):
|
||||
"""
|
||||
Returns a generic FileResponse from the given path
|
||||
|
|
Loading…
Reference in a new issue