responses
ResponseMixin
¶
Mixin providing standardized API response methods.
Ensures consistent response formatting across all API endpoints and provides response methods that correspond to the standardized schema objects defined in this module.
Usage
class MyView(ResponseMixin, APIView): def get(self, request): return self.success_response({"data": "example"})
Schema Integration
Each method in this mixin corresponds to a schema object: - success_response() -> successResponseSchema (200) - accepted_response() -> acceptedResponseSchema (202) - no_content_response() -> noContentResponseSchema (204) - bad_request_response() -> badRequestResponseSchema (400) - not_found_response() -> notFoundResponseSchema (404) - not_acceptable_response() -> notAcceptableResponseSchema (406)
accepted_response(data)
¶
Return standardized accepted response. Corresponds to: acceptedResponseSchema (202)
bad_request_response(error_message, status_code=rest_framework.status.HTTP_400_BAD_REQUEST)
¶
Return standardized bad request response. Corresponds to: badRequestResponseSchema (400)
no_content_response(data=None, message=None)
¶
Return standardized no content response. Corresponds to: noContentResponseSchema (204)
not_acceptable_response(message)
¶
Return standardized not acceptable response. Corresponds to: notAcceptableResponseSchema (406)
not_found_response(message)
¶
Return standardized not found response. Corresponds to: notFoundResponseSchema (404)
success_response(data, status_code=rest_framework.status.HTTP_200_OK)
¶
Return standardized success response. Corresponds to: successResponseSchema (200)