Django-Tastypie has an ImmediateHttpResponse exception, which allows you to immediately return a response to the client:
raise ImmediateHttpResponse(response='a message')
Django has Http404 , but I could not find a more universal exception like ImmediateHttpResponse .
What technique do you use to return an immediate 400 response to a customer?
For example, with a model:
class Subscriber(Model): def delete(self, *args, **kwargs): raise ImmediateHttpResponse('Deleting subcribers is not allowed!')
and an attempt to delete the object will return a 400 response to the client with this message.
source share