Json Response for http error codes
Project description
Django Error Response In Json
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:
- Contribute (https://github.com/subodh358/django_status_response)
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django_json_error_response-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2d13b6216145cb4e767123b4b76bdc290db40ae4d9a9c386eda63e93196be96 |
|
MD5 | 6c78b972564fa41cf27487033e675438 |
|
BLAKE2b-256 | d2ec1a9ae7afdcacdf1a6f13f4ae9edf5171c031f8a484ee3b109542da35481a |
Close
Hashes for django_json_error_response-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bb977be4db7f37b993844e20bf0ca75cb9ee392cbd77930b4fe752c31fc7b3a |
|
MD5 | ee201a24eea4c0deab23e270befd0bf0 |
|
BLAKE2b-256 | cd8026c458012a5378d10f554ba78fcfe50c6d1e892f35b8b63e35950d6c7d1f |