Created
July 9, 2013 07:00
-
-
Save theeluwin/5955244 to your computer and use it in GitHub Desktop.
Making PUT and DELETE method reasonable for restful django.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def refine(request): | |
| method = request.method | |
| if method == 'PUT' or method == 'DELETE': | |
| if hasattr(request, '_post'): | |
| del request._post | |
| del request._files | |
| try: | |
| request.method = 'POST' | |
| request._load_post_and_files() | |
| request.method = method | |
| except AttributeError: | |
| request.META['REQUEST_METHOD'] = 'POST' | |
| request._load_post_and_files() | |
| request.META['REQUEST_METHOD'] = method | |
| request.PUT = request.POST | |
| request.DELETE = request.POST | |
| return request |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment