Skip to content
This repository was archived by the owner on May 2, 2023. It is now read-only.

Responses format

Alexandre Nucera edited this page Mar 19, 2015 · 6 revisions

Success

To return a response to the client, your method must return a django.http.HttpResponse. To facilitate its use, a method response in the class API have been created. You can send your data object to this method , and the return HTTP code that you want:

return self.response(data, code=201)

Errors

For facilitate the error handling, you can raise an rest_api.errors.ResponseError whenever you need to return a response error. Some custom ResponseError are already defined (ResponseNotFound, ResponseForbidden, ...). You could check out some examples in project.py.

Clone this wiki locally