I need tastypie to return a queryset with different filters depending on which data is sent via POST. I found out that if I override get_object_list
I get the behavior I need but this just works for the GET request. I wanted to know if there is a way to achieve something similar but while doing a POST request.
Thanks :)
You should use GET only to get data HTTP convention.
All the methods are meant for some purpose to keep it simple and specific. It always helps in debugging logs.
If you still want to use POST to get some data. You can use below example.
class ModelResource(Resource):
class Meta:
resource_name = 'api'
detail_allowed_methods = ['post']
authorization = Authorization()
authentication = OAuth20Authentication()
always_return_data = True
default_format = "application/json"
def post_list(self, request, **kwargs):
self.method_check(request, allowed=['post'])
# Do any operation here and return in form of json in next line
return self.create_response(request, <return json>)