Skip to main content

Provide a workaround to use different method from GET or POST inside HTML forms

Project description

Python package codecov CodeFactor PyPI Version Python 3.5+ Django 2+, 3+ License MIT


Provide a workaround to use different method than GET or POST inside HTML forms in django templates. Works only with Class Based View.


From source code:

python install

From pip:

pip install django-http-method


Add django_http_method to your settings.INSTALLED_APPS
Add the mixin to a CBV
from django.views.generic import View
from django_http_method import HttpMethodMixin

class TestView(HttpMethodMixin, View):
	def get(self, request):
	def delete(self, request):
	def put(self, request):
In your template, load http_method and use {% http_[method] %} in your forms:
{% load http_method %}

<form action="/" method="post">
    {% csrf_token %}
    {% http_put %}
    <button type="submit">Send a PUT request</button>

<form action="/" method="post">
    {% csrf_token %}
    {% http_patch %}
    <button type="submit">Send a PATCH request</button>

The corresponding method of your View will now be called. For instance, if {% http_put %} was used, then TestView.put() will be called and any request parameter will be in request.PUT.



  • Dropped Django 1.X support.
  • Now supports Django 3.2.


  • Now use Github action for testing and deployment


  • Dropped python 3.4 support
  • Now support django 3.0


  • Added pyaml to setup requirement.


  • Now use yaml.safe_load() instead of yaml.load()
  • Added python 3.7 and django 2.1 to test matrix


  • Initial release for python3.4+ and django1.8, 1.10, 1.11 and 2.0+


  • Will now search for parameters in body for methods PUT and PATCH
  • Method will default to request.method if '_method' parameter was not found


  • Added end slash '/' at the end of HTML input in templatetags


  • Removing '_method' from request parameters

Download files

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

Files for django-http-method, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size django-http-method-1.2.0.tar.gz (7.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page