Skip to main content

Return HTTP responses in a easier way

Project description

settings.py

MIDDLEWARE_CLASSES = (
    ...
    # last on the list
    django_simple_response.middleware.SimpleResponseMiddleware,
)

views.py

def view(request):
    # return HTTP response with status code 200 (default)
    return

def another_view(request):
    # return HTTP response with content and status code 401
    return 401, 'Not authorized'

def yet_another_view(request):
    # return JSON/JSONP response with content and default status code
    return {'foo': 'bar'}

In a nutshell, you can either return:

  1. an object, which will be serialized into the response’s content.

  2. a tuple, which first element defines the status code and the second the content of the response.

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-easy-response-1.0.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

django_easy_response-1.0.0-py2-none-any.whl (6.5 kB view details)

Uploaded Python 2

File details

Details for the file django-easy-response-1.0.0.tar.gz.

File metadata

File hashes

Hashes for django-easy-response-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0d6baf24049a91965be63c15782c26d33ec8451c0e7b3708a7f50fa2780d777d
MD5 cbe8dd7a2c0a0c00826490911f16d9a9
BLAKE2b-256 c6566b01bcc714fa3b16c60fbcf4d2c5ece7ca201bb384595d7506402d8df0b7

See more details on using hashes here.

File details

Details for the file django_easy_response-1.0.0-py2-none-any.whl.

File metadata

File hashes

Hashes for django_easy_response-1.0.0-py2-none-any.whl
Algorithm Hash digest
SHA256 ab8ac49aa812d88935d14711c689a95ad1af70096dd23b37884bb508e7faa258
MD5 0cf759b7f5b290dc4428679a52eeca72
BLAKE2b-256 f698eca5bee4484556957fa208727cc58d1e92cac397bf81ff3fbc5cc98a8a22

See more details on using hashes here.

Supported by

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