[Answer]-Django calling function of one to one relation

1👍

Not sure, if I get your question right, but you have access to the self.information object or is it None?

If exists, have you tried str(self.information)? This should call the str function of your object.
So, the str method of the Contact Model could look like the following:

 #Contact Model
 def __str__(self):
        if self.information.first_name is not None and self.information.last_name is not None:
            return str(self.information)
        return 'new contact'

Leave a comment