Skip to main content

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

Project description

docs

Documentation Status

tests

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.

Installation

pip install django-accept-header

Usage

First add the middleware to your settings.py file:

MIDDLEWARE_CLASSES = (
    # ...
    'django_accept_header.middleware.AcceptMiddleware',
)

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.

Documentation

https://django-accept-header.readthedocs.org/

Development

To run the all tests run:

tox

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.

Source Distribution

django-accept-header-0.3.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

django_accept_header-0.3.2-py2.py3-none-any.whl (17.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-accept-header-0.3.2.tar.gz.

File metadata

File hashes

Hashes for django-accept-header-0.3.2.tar.gz
Algorithm Hash digest
SHA256 343f1b1230ad06f4ba3165b07781476df4dfe00f725c07f9a57e032f7ae712a9
MD5 1126dae9dc1b73f990f70417b1aaf237
BLAKE2b-256 f7450b8380ae5545ff4d893571bf24746130c5bd2a4b141e3c645e1a2e5dac4a

See more details on using hashes here.

File details

Details for the file django_accept_header-0.3.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_accept_header-0.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a7765fe1290e182df0d231f1e63a8a016b880ac45fea13a3eeffbf26c3e3629c
MD5 e19c7bff8005f2c2da54166fa437cb2d
BLAKE2b-256 46bfc10ce3c5bd225f792de571241932ee4634a5b33e629d3170530c33b93f46

See more details on using hashes here.

Supported by

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