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.2b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4edd8f6a8c11779900d62f5a00c211bb54f09886837ce492e2bbbc2aaf97631a |
|
MD5 | ba9aed7d828d249b5b367b2d1f8a1e83 |
|
BLAKE2b-256 | 709e4b560a9b4b3b54e59b1cdb24c34366eb13774b4244f1aa6d6d405504ae61 |
Close
Hashes for django_saccess_response-1.0.2b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a0068200d48d314aaa40625985cf37f2bc2183dfcbb225f289994f29a7b9fc7 |
|
MD5 | f52da6c23606bca13f2fac362757e2c8 |
|
BLAKE2b-256 | 9ba398c7f5226297618c5ac44650b8a18f53023a10fca833cf52342487a8e976 |