1👍
✅
The issue is in your get_object
method, you’re returning a 404 response instead of raising a Http404
exception. Because of that, the Response
is being passed into your serializer, and clearly the Response
does not have a username
field.
The last part of your stack trace said
Original exception text was: ‘Response’ object has no attribute ‘username’.
Which was the signal: there is only one place where you are returning a Response
back to a serializer.
Source:stackexchange.com