Django app for customizing response
Project description
Django rest framework app for customizing response data
Installation
pip install django-saccess-response
Usage
from django_saccess_response import SaccessResponse
from rest_framework.views import APIView
class MyView(APIView):
@staticmethod
def get(request):
data = {'key': 'value'}
return SaccessResponse(data)
result:
{
"status": true,
"result": {
"key": "value"
}
}
Error Handling
from django_saccess_response import SaccessResponse
from rest_framework.views import APIView
class MyView(APIView):
@staticmethod
def get(request):
data = {'key': 'value'}
return SaccessResponse(data, saccess=False)
result:
{
"status": false,
"result": {
"detail": "error"
}
}
Custom Django Rest Framework error handling
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'saccess_response.views.saccess_exception_handler'
}
Ganeric View and ViewSet class name
- CreateAPIView:
SaccessCreateAPIView
- RetrieveAPIView:
SaccessRetrieveAPIView
- UpdateAPIView:
SaccessUpdateAPIView
- DestroyAPIView:
SaccessDestroyAPIView
- ListAPIView:
SaccessListAPIView
- RetrieveUpdateAPIView:
SaccessRetrieveUpdateAPIView
- RetrieveDestroyAPIView:
SaccessRetrieveDestroyAPIView
- RetrieveUpdateDestroyAPIView:
SaccessRetrieveUpdateDestroyAPIView
- ModelViewSet:
SaccessModelViewSet
- ReadOnlyModelViewSet:
SaccessReadOnlyModelViewSet
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_saccess_response-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 667ec39c4ad38e44fefb2c2c7a6d33dfc44fdd2f468c8c46c90cf799b9ee1648 |
|
MD5 | 7197fbea08def3766c6d7ea27f392985 |
|
BLAKE2b-256 | c5973f822630bd171926531e2eec53c0b111cb4eb3918b2957ac7c71ad6bfbfa |
Close
Hashes for django_saccess_response-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4b238eb8755516b82e7f4d6a11e554725c857e68cf9492133f60c3794603c4d |
|
MD5 | 825680f285e8665a615a826fa84b9f4b |
|
BLAKE2b-256 | 6cd748a13c262c96632650fe23920a64d31a60bd2d28bb9f222d36c8fb91370a |