Answer the question
In order to leave comments, you need to log in
How to return an empty value?
Model
def get_profile_cover_picture(self):
default_cover = None
if self.cover:
return self.cover.url
else:
return default_cover
def get_profile_cover_picture(self, obj):
request = self.context.get('request')
profile_cover_picture_url = obj.get_profile_cover_picture()
return request.build_absolute_uri(profile_cover_picture_url)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question