Django Accept Headers
docs |
|
|---|---|
tests |
|
package |
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
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.
Metadata
Release files for django-accept-header 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-accept-header-0.3.2.tar.gz | 11.8 kB | Without provenance | Details for django-accept-header-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_accept_header-0.3.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for django_accept_header-0.3.2-py2.py3-none-any.whl |
Total release size: 29.2 kB
Release files / django-accept-header-0.3.2.tar.gz
| Download URL | django-accept-header-0.3.2.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
343f1b1230ad06f4ba3165b07781476df4dfe00f725c07f9a57e032f7ae712a9
|
|
BLAKE2b-256 checksum How to use checksums |
f7450b8380ae5545ff4d893571bf24746130c5bd2a4b141e3c645e1a2e5dac4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_accept_header-0.3.2-py2.py3-none-any.whl
| Download URL | django_accept_header-0.3.2-py2.py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a7765fe1290e182df0d231f1e63a8a016b880ac45fea13a3eeffbf26c3e3629c
|
|
BLAKE2b-256 checksum How to use checksums |
46bfc10ce3c5bd225f792de571241932ee4634a5b33e629d3170530c33b93f46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-accept-header 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.