Django app for customizing response
View the Project on GitHub QuvonchbekBobojonov/django-success-response
To install django-success-response
, follow these simple steps:
pip
You can easily install the django-success-response
package using pip
:
pip install django-success-response
This command will install the package and all its dependencies.
Once the package is installed, you need to add success_response
to your INSTALLED_APPS
in your Django project’s settings.py
file:
INSTALLED_APPS = [
# Other apps
'success_response',
]
django-success-response
extends Django REST Framework’s response handling. To ensure that error responses are formatted consistently, you can update your Django settings to use the custom exception handler provided by the package.
In your settings.py
, add or update the following configuration:
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'success_response.views.success_exception_handler',
}
This will ensure that all error responses are formatted in the SuccessResponse
structure.
By default, SuccessResponse
wraps the response data with a success
field and a result
field. You can customize this behavior by modifying the response structure in your views or global settings as needed.