How can I have the django message framework work with the rest_framework?
Here is my view
@api_view(['GET', 'POST'])
def myview(request):
if request.method == 'GET':
#return a Response object
else:
#process post data
messages.success(request, 'Success')
return Response(response)
I encounter the following error
add_message() argument must be an HttpRequest object, not 'Request'
which is because the rest_framework
does not use the normal HttpRequest
object, used
in django by default.
How can I use messaging framework with rest framework?
DRF views do not use
HttpRequest
but userest_framework.request.Request
, (read here) you can access to the object that you need usinganyway this code have sense only if you are using
BrowsableAPIRenderer