Adam
Adam

Reputation: 1744

Django 1.8 PUT and DELETE method simple implementation

I've a project that need integration with PUT and DELETE method recently. However it has being quite large for me to refactory it using Django Restful Project. How can I get PUT and DELETE method, and its data like POST simply?

Is there a quick middleware for it?

Thx in advance.

Upvotes: 1

Views: 857

Answers (2)

Alasdair
Alasdair

Reputation: 309099

You can see how Django constructs the POST data from request.body in the source code. You should be be able to do something similar.

Assuming the PUT data is form encoded:

from django.http.request import QueryDict

def my_put_view(request):
   if request.method = 'PUT':
       PUT = QueryDict(self.body, encoding=request._encoding), MultiValueDict()
       # do something with PUT

Upvotes: 1

Bogdan Goie
Bogdan Goie

Reputation: 1307

Have a read here, I think this might be what you are looking for.

You can use the so called POST TUNNELLING method, that is using a POST request, putting the HTTP header X_METHODOVERRIDE in the request.

Upvotes: 1

Related Questions