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.2b2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a44e397548234fc84be9aee0496e642b7977d72d669e0126ef0390e53950254 |
|
MD5 | 286caf6daa99400ddf79f692e4fe6744 |
|
BLAKE2b-256 | e968d7fd843dd0a272c342e0fdfc6eab41acdd096b28c05e7a2305ac090cc4b7 |
Close
Hashes for django_saccess_response-1.0.2b2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 555b8d92abd05659c10ed918bb9018988005e4d706d63e5582a1116fae31dae3 |
|
MD5 | c6f8d22a1309f020e57cfabe135c8056 |
|
BLAKE2b-256 | 8f1fcf05d759fc8c94b86c25d98181dea6743ebaa1322a693c214f9dd1d8dcc6 |