# in your_project/utils.py or a similar file

from rest_framework.views import exception_handler

def custom_exception_handler(exc, context):
    response = exception_handler(exc, context)

    if response is not None:
        response.data = {
            "status": response.status_code,
            "data": {},
            "message": str(exc.detail) if hasattr(exc, 'detail') else str(exc)
        }

    return response
