Django Success Response
django-success-response is a Django REST Framework extension that standardizes success and error response formats in API views. It simplifies response handling by providing a consistent structure and offers easy customization for data formats.
Official Docs: django-success-response.moorfo.uz
Installation
Install the package via pip:
pip install django-success-response
Usage
Standard Success Response
To return a standard success response, use SuccessResponse in your Django views.
Example:
from success_response.response import SuccessResponse
from rest_framework.views import APIView
class MyView(APIView):
@staticmethod
def get(request):
data = {'key': 'value'}
return SuccessResponse(data)
Response:
{
"success": true,
"result": {
"key": "value"
}
}
Error Response
For error responses, set success=False and provide an error message.
Example:
from success_response.response import SuccessResponse
from rest_framework.views import APIView
class MyView(APIView):
@staticmethod
def get(request):
data = {'message': 'error'}
return SuccessResponse(data, success=False)
Response:
{
"success": false,
"error": {
"message": "error"
}
}
Error Handling
To format all error responses using the SuccessResponse structure, configure the EXCEPTION_HANDLER in your settings.py:
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'success_response.views.success_exception_handler'
}
Generic Views and ViewSets
django-success-response provides customized DRF generic views and viewsets that automatically return responses in the SuccessResponse format.
Available Views and ViewSets:
| Standard View | Success Equivalent |
|---|---|
CreateAPIView |
SuccessCreateAPIView |
RetrieveAPIView |
SuccessRetrieveAPIView |
UpdateAPIView |
SuccessUpdateAPIView |
DestroyAPIView |
SuccessDestroyAPIView |
ListAPIView |
SuccessListAPIView |
RetrieveUpdateAPIView |
SuccessRetrieveUpdateAPIView |
RetrieveDestroyAPIView |
SuccessRetrieveDestroyAPIView |
RetrieveUpdateDestroyAPIView |
SuccessRetrieveUpdateDestroyAPIView |
ModelViewSet |
SuccessModelViewSet |
ReadOnlyModelViewSet |
SuccessReadOnlyModelViewSet |
These views behave like their DRF counterparts but automatically format responses using SuccessResponse.
Metadata
Release files for django-success-response 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_success_response-1.1.2.tar.gz | 7.2 kB | Without provenance | Details for django_success_response-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_success_response-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for django_success_response-1.1.2-py3-none-any.whl |
Total release size: 17.5 kB
Release files / django_success_response-1.1.2.tar.gz
| Download URL | django_success_response-1.1.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
325acc5186ba13df26af94a6aade749f224a2d47f15fc942885912744e665d50
|
|
BLAKE2b-256 checksum How to use checksums |
59981dd244f15a692c966a68778572a3df7781e843c3e0cd2a607b4ca31807af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.6
|
Release files / django_success_response-1.1.2-py3-none-any.whl
| Download URL | django_success_response-1.1.2-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b639f6a3581f3fcca5b0c12be2ae290f061a271cf6218438242e398c231a40c3
|
|
BLAKE2b-256 checksum How to use checksums |
83bebfbc42031f82d92149d3c82531c991651842e7bef3cabc5d4ec9060bed0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.6
|
Security for django-success-response 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.