Skip to content

Instantly share code, notes, and snippets.

@khamidou
Created August 8, 2011 17:06
Show Gist options
  • Save khamidou/1132206 to your computer and use it in GitHub Desktop.
Save khamidou/1132206 to your computer and use it in GitHub Desktop.
def convert_overloaded_post(request):
"""
Convert a POST method with a hidden field
named _method to a PUT or a DELETE
"""
request._load_post_and_files()
if request.method == "POST":
if hasattr(request.POST, "_method"):
if request.POST["_method"] == "PUT":
request.method = "PUT"
request.PUT = request.POST
elif request.POST["_method"] == "DELETE":
request.method = "DELETE"
return request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment