Django app for customizing response
Project description
Django rest framework app for customizing response data
Installation
pip install django-saccess-response
Usage
from saccess_response.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 saccess_response.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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27c9c9ea2f2cef638506c4a4cacdf2c3f6c7b0d5bb418286fd690cc561cd4a5c |
|
MD5 | b57e0a31fca18b3c0fca48dfbda599d7 |
|
BLAKE2b-256 | ad3be24311b699619e8e4b7eec4c6da89074e85a9475ad24b322f7b9f7ff27f0 |
Close
Hashes for django_saccess_response-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c41700c0dcc8f2c53aaafdbc899043a4b99d6f3d039e225b54c43cf65583a3a |
|
MD5 | 9eef5e5993e8f16b084d05a14d4796aa |
|
BLAKE2b-256 | 44aca2138d9dce26a6d5e77c242c381a2eba07cee2a5fa349dfae5716f8b77cc |