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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cba9b6ee817f0b128e855702dc90e058474040624a761ab8955c4d666baba2b8 |
|
MD5 | 43b292f0849130696a8f8eb283f3be9d |
|
BLAKE2b-256 | 2802557f9448a5d07aac00d88365b62211d82a30d4aae3f9920de7bfec7db815 |
Close
Hashes for django_saccess_response-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc34597756f2ff234167ea3c295e3fba5829db99ea10d10b27ecb2a8508c2c0c |
|
MD5 | 41cb3e9103b61c55268131df26f06698 |
|
BLAKE2b-256 | b1bc8e922b70924d881a05f0d77d80a2fe71f6078d1a885c21cb4b93e1a01608 |