Skip to main content

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

Project description

Build Status PyPI Version Coverage Status Python 3.4+ Django 1.8, 1.10, 1.11, 2.0+ 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):
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.



  • Removing '_method' from request parameters

Project details

Download files

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

Source Distribution

django-http-method-0.3.0.tar.gz (4.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page