Skip to main content

A Django middleware that inspects the HTTP Accept headers sent by browsers.

Project description

docs Documentation Status
Travis-CI Build Status Requirements Status
Coverage Status

package PyPI Package latest release PyPI Package monthly downloads PyPI Wheel Supported versions Supported implementations

A Django middleware that inspects the HTTP Acept headers sent by browsers. It adds a new method to each request instance called accepts(str) which can be used to determine if a certain mimetype is accepted by the user agent that issued the request.


pip install django-accept-header


First add the middleware to your file:

    # ...

To check if the text/plain mimetype is accepted by the user agent:

def some_view(request):
    if request.accepts('text/plain'):
        # do something

The ordered list of accepted mimetypes can also be used:

def some_view(request):
    for media_type in request.accepted_types:
        # do something

See the full documentation for how to use the media types please see the full documentation.


To run the all tests run:


0.3.0 / 2016-02-02

  • Change package name to django-accept-header.
  • Make python3.5 the default version used for tests.

0.1.0 / 2015-11-26

  • First release on PyPI.

Project details

Download files

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

Files for django-accept-header, version 0.3.2
Filename, size File type Python version Upload date Hashes
Filename, size django_accept_header-0.3.2-py2.py3-none-any.whl (17.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-accept-header-0.3.2.tar.gz (11.8 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