2👍
✅
Calling .url
raises an exception if obj.image
is None
.
You can update get_image_url
as follows:
def get_image_url(self, obj):
if obj.image:
return obj.image.url
else:
return None
Source:stackexchange.com