Django: Why do some model fields clash with each other?

You have two foreign keys to User. Django automatically creates a reverse relation from User back to GameClaim, which is usually gameclaim_set. However, because you have two FKs, you would have two gameclaim_set attributes, which is obviously impossible. So you need to tell Django what name to use for the reverse relation.

Use the related_name attribute in the FK definition. e.g.

class GameClaim(models.Model):
    target = models.ForeignKey(User, related_name="gameclaim_targets")
    claimer = models.ForeignKey(User, related_name="gameclaim_users")
    isAccepted = models.BooleanField()

Leave a Comment