1

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.

0

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

I'm sorry I cannot change the js part. It is sent here via $.ajax's PUT and data.
I don't think Django constructs any dicts for PUT and DELETE from what I know. Here is the reasoning: groups.google.com/forum/#!msg/django-developers/dxI4qVzrBY4/…
By the way, you could get the data from the request in request.body if you need to have access to it.
Could you give me an example that how can I parse the request.body?
You can inherit in Django the View class and override ...the dispatch method to have access to the request if you want; reference -> docs.djangoproject.com/en/1.8/ref/class-based-views/base/…
1

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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.