1π
β
To display a human-readable representation you should write a __str__
(if using python2 the name should be __unicode__
) method on the model. Django admin will use this method to display the instances, you donβt need to override or customize anything in admin.py for this.
In your case, like this:
class SocialProfile(models.Model):
user = models.OneToOneField(User, unique=True)
follows = models.ManyToManyField('self', related_name='followed_by', symmetrical=False)
def __str__(self):
"""Return human-readable representation"""
return self.user.username
π€danielcorreia
Source:stackexchange.com