Skip to content

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

License

Notifications You must be signed in to change notification settings

fladi/django-accept-header

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3c102ba · Sep 27, 2016

History

16 Commits
Feb 2, 2016
Sep 27, 2016
Sep 27, 2016
Feb 2, 2016
Nov 30, 2015
Nov 30, 2015
Nov 30, 2015
Dec 1, 2015
Nov 30, 2015
Feb 2, 2016
Dec 1, 2015
Nov 30, 2015
Feb 2, 2016
Feb 2, 2016
Nov 30, 2015
Feb 2, 2016
Feb 2, 2016

Repository files navigation

Django Accept Headers

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages