Skip to main content

Raise any response object in Django

Project description

django-raise-response

django-raise-response is a simple plugin that provides the ability to return any response by raising it as you would do with django.http.Http404

Why would you need this? If you need to return a non-4XX/5XX response from a class-based view, for example a 303/301 response, this is the only decent way to do it.

Installing

pip install django-raise-response

Then add ‘raiseresponse.middlewares.RaiseResponse’ to your middlewares:

MIDDLEWARE = [
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'raiseresponse.middlewares.RaiseResponse'
]

Usage

Now you can use ResponseError to raise any response:

from raiseresponse import ResponseError

# somewhere in your view
response_you_want_to_rise = HttpResponse()
raise ResponseError(response_you_want_to_rise)

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-raise-response-0.1.0.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_raise_response-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file django-raise-response-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django-raise-response-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d1baec9c9b3537dd4e185ce4703e3f2f4c679d2d97e95be925ac604197a21c5d
MD5 6643a300c01a07ecd0ea576cf16a169a
BLAKE2b-256 18af03f49e09f4037a223a96e5d8057b6e6809df3e81dd819568209feae19f6c

See more details on using hashes here.

File details

Details for the file django_raise_response-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_raise_response-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b640557bf394b86df9dca386a7018f16f1ef1e6622f588aa548c5006c04af82
MD5 6e6e7af80c32e43324c6ac8bde741b8f
BLAKE2b-256 4e139ba06e3bc46a9728436eb34c2033398441533d43955d36735a8700d6bba1

See more details on using hashes here.

Supported by

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