[Answer]-Issues with admin part

1👍

You’re not populating the Drinker.name field.
The row is blank because the unicode() method is returning nothing.

One way to solve this would be to set it explicitly in the signal handler:

def create_drinker_user_callback(sender, instance, **kwargs):
      drinker, new=Drinker.objects.get_or_create(user=instance, name=instance.get_full_name())
post_save.connect(create_drinker_user_callback, User)

or ditch the (possibly redundant) name field altogether and normalise it a bit:

class Drinker(models.Model):
    user = models.OneToOneField(User)
    birthday = models.DateField()

    def __unicode__(self):
        return self.user.get_full_name()
👤moopet

Leave a comment