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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

Supported by

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