Skip to main content

Json Response for http error codes

Project description

Django Error Response In Json

Build Status

django_json_error_response is ready to use library for django to show response in customized JsonResponse.

New Features!

  • Easy to use response than generic JsonResopnse.
  • Support django-3+ version (Self Tested)

You can also:

Use:

from django_json_error_response.http import (
        Http400Response,
        Http403Response,
        Http404Response,
        Http500Response,
        SuccessResponse,
        ErrorResponse
    )
#code lines
def my_view(request):
    if my_condition :
        #your code
        return SuccessResponse(message=my_message)  #default status is 200 for this response
    else:
        return ErrorResponse(message=my_message, status=status_code) #status_code can be anything that you want to respond with.

def my_custom_view(request):
    if condition:
        #your code
        return SuccessResponse(message=my_message)
    else:
        Http404Response(message=my_message)

For ErrorResponse()

ErrorResponse take two arguments ~ message ~ status (for error except 404,403,400,500)

Exra information

You can also pass json data insted of message or both at same time in every Resonse.

License

MIT

Free Software, Hell Yeah!

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_json_error_response-0.1.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

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

django_json_error_response-0.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file django_json_error_response-0.1.tar.gz.

File metadata

  • Download URL: django_json_error_response-0.1.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for django_json_error_response-0.1.tar.gz
Algorithm Hash digest
SHA256 c2d13b6216145cb4e767123b4b76bdc290db40ae4d9a9c386eda63e93196be96
MD5 6c78b972564fa41cf27487033e675438
BLAKE2b-256 d2ec1a9ae7afdcacdf1a6f13f4ae9edf5171c031f8a484ee3b109542da35481a

See more details on using hashes here.

File details

Details for the file django_json_error_response-0.1-py3-none-any.whl.

File metadata

  • Download URL: django_json_error_response-0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for django_json_error_response-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9bb977be4db7f37b993844e20bf0ca75cb9ee392cbd77930b4fe752c31fc7b3a
MD5 ee201a24eea4c0deab23e270befd0bf0
BLAKE2b-256 cd8026c458012a5378d10f554ba78fcfe50c6d1e892f35b8b63e35950d6c7d1f

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