I found success by doing the following:
File myapp.view.py:
def jwt_response_payload_handler(token, user=None, request=None): return { 'token': token, 'bunny': 'fu fu' }
settings.py file:
JWT_AUTH = { 'JWT_RESPONSE_PAYLOAD_HANDLER': #'rest_framework_jwt.utils.jwt_response_payload_handler', 'myapp.views.jwt_response_payload_handler', }
The jwt_response_payload_handler function is jwt_response_payload_handler in an arbitrary place, but make sure it is in your python path. For example, in this file: myapp.views.py
Then, in the settings.py file, update the JWT_AUTH jwt_response_payload_handler dictionary key with the new location created by jwt_response_payload_handler .
Once you understand what is happening, you can adapt the solution as you want. For example, I would not recommend leaving an overridden function in the views.py file. It was just easier to demonstrate goals.
Placing the jwt_response_payload_handler function in your helper.py file might be a simple solution.
aero
source share