Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Django Middleware for HTTP Method Override Form Params & Header

Project description

Django Method Override

Django middleware that overrides the HTTP method through either a `_method` form param (Ruby on Rails style) or the X-HTTP-Method-Override header.


1. Install via pip:

$ pip install django-method-override

2. Add the `MethodOverrideMiddleware` **after** Django's `CsrfViewMiddleware`:

# ...
# ...

3. Add `method_override` to your `INSTALLED_APPS`:

# ...


Use the provided template tag in your form to add the desired form:

{% load method_override %}
<form action="{% url 'post-detail' %}" method="POST">
{% csrf_token %}
{% method_override 'PUT' %}

Now, you may use `put` in you Class-based views. Django Method Override will even copy over the form data to `request.PUT`:

class PostView(View):
def put(self, request):
form = Form(request.PUT)
# ...

The X-HTTP-Method-Override header is also supported. So for the above view, this will work too:

'headers': {'X-HTTP-Method-Override': 'PUT'},
'type': 'POST',
'url': 'http://localhost:8000/posts/1/',
// ...


Django Method Override can be customized from your Django `` file:


A list of the allowed methods for overriding. Defaults to:



The form param key used to override the method. Defaults to `'_method'`.


The HTTP header to check. Defaults to `'HTTP_X_HTTP_METHOD_OVERRIDE'`


The string tempalte used to render the input for the form param. It will based to kwargs, `name` and `value`. Defaults to:

'<input type="hidden" name="{name}" value="{value}">'


Copyright (c) 2013 [LocalMed, Inc.]( See LICENSE for details.

Project details

Release history Release notifications

This version
History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-method-override-0.2.0.tar.gz (4.2 kB) Copy SHA256 hash SHA256 Source None Aug 31, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page