Skip to main content

Django Saccess Response

django-saccess-response is a Django REST Framework extension that provides a standardized success response format for API views. It simplifies handling both successful and error responses with customizable data structures.

Installation

Install the package via pip:

pip install django-saccess-response

Usage

In your Django views, use SaccessResponse to wrap the response data.

Example: Standard Success Response

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:

{
    "success": true,
    "result": {
        "key": "value"
    }
}

Example: Error Response

To handle errors, pass saccess=False:

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:

{
    "success": false,
    "result": {
        "detail": "error"
    }
}

Error Handling

You can also customize Django REST Framework's error responses globally by modifying the EXCEPTION_HANDLER setting in your settings.py:

REST_FRAMEWORK = {
    'EXCEPTION_HANDLER': 'saccess_response.views.saccess_exception_handler'
}

This will format all exceptions using the SaccessResponse structure.

Generic Views and ViewSets

This package also provides customized DRF generic views and viewsets for standardized response handling.

Standard View Saccess Equivalent
CreateAPIView SaccessCreateAPIView
RetrieveAPIView SaccessRetrieveAPIView
UpdateAPIView SaccessUpdateAPIView
DestroyAPIView SaccessDestroyAPIView
ListAPIView SaccessListAPIView
RetrieveUpdateAPIView SaccessRetrieveUpdateAPIView
RetrieveDestroyAPIView SaccessRetrieveDestroyAPIView
RetrieveUpdateDestroyAPIView SaccessRetrieveUpdateDestroyAPIView
ModelViewSet SaccessModelViewSet
ReadOnlyModelViewSet SaccessReadOnlyModelViewSet

These classes behave like their DRF counterparts but automatically format responses using SaccessResponse.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for django-saccess-response 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-saccess-response 1.0.5
File Size Uploaded Provenance Actions
django_saccess_response-1.0.5.tar.gz 5.9 kB Without provenance Details for django_saccess_response-1.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-saccess-response 1.0.5
File Interpreter ABI Platform Actions
django_saccess_response-1.0.5-py3-none-any.whl Python 3 none any Details for django_saccess_response-1.0.5-py3-none-any.whl

Total release size: 14.7 kB

Release files / django_saccess_response-1.0.5.tar.gz

Download URL django_saccess_response-1.0.5.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4330f1a09e1d15b68aadbb0e74dadabfa2e5dc3c9a007e7fc0e79ddb9ced84e8
BLAKE2b-256 checksum
How to use checksums
87bf628f25bfa1f981a7a3d3d66dd06a09b1f30bc4e358647a6695c859cb3ff8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.6

Release files / django_saccess_response-1.0.5-py3-none-any.whl

Download URL django_saccess_response-1.0.5-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bba7897ea18ca12c245092d5ca1a794b51262d901c90d7a3374b595b9973c36a
BLAKE2b-256 checksum
How to use checksums
8bd9e91205e2062f0d95b58861f474f73d5eb084f562f502ad43bfec96fcecd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.6

Security for django-saccess-response 1.0.5

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page