1👍
✅
self.related.model.DoesNotExist
means that there is no Parts
instance for the Main
object that haystack is indexing at the time of the error. You can catch the exception and just return an empty string ""
in that case:
# ...
def prepare_parts(self, obj):
try:
return obj.mainparts.parts
except Parts.DoesNotExist:
return ""
# ...
👤sk1p
Source:stackexchange.com