Skip to content
Advertisement

AttributeError: ‘NoneType’ object has no attribute ‘build_absolute_uri’ Django Rest Framework

I’ve got this Serializer translating path to url, and it works on its own, but when i try to nest this serializer inside another serializer, i get this error. Do you have any idea why? I need to have this function, because otherwise it just shows the paths to the image in this main SpecialistSerializer.

JavaScript
JavaScript

Traceback:

JavaScript
JavaScript

Advertisement

Answer

In to_representation, you access to the EntityPhotosSerializer. And in that serializer, you are trying to access to the context. If you want to do that, you need to pass the current context to EntityPhotosSerializer in SpecialistSerializer.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement