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

后端 未结 6 2304
南笙
南笙 2020-11-29 16:10

I want to create an object that contains 2 links to Users. For example:

class GameClaim(models.Model):
    target = models.ForeignKey(User)
    claimer = mod         


        
6条回答
  •  孤城傲影
    2020-11-29 16:54

    The User model is trying to create two fields with the same name, one for the GameClaims that have that User as the target, and another for the GameClaims that have that User as the claimer. Here's the docs on related_name, which is Django's way of letting you set the names of the attributes so the autogenerated ones don't conflict.

提交回复
热议问题