[Answer]-Separate functions for Get, POST, PUT and DELETE in django-tastypie


You should override the dispatch method from the Resource, and there create each one of your functions. If you want to do some simple logic, you would place your code after the call to the Resource original dispatch. The code would look something like this:

def dispatch(self, request_type, request, **kwargs):
    response = super(Resource, self).dispatch(request_type, request, **kwargs)

    # Pass any parameters that you require to the functions
    if request.method == 'GET':
    if request.method == 'POST':
    if request.method == 'PUT':
    if request.method == 'DELETE':

    return response

In general terms it should be enough for your purpose, except if you want to do some more complex stuff with the response.

Leave a comment