Multiple many-to-many relations to the same model in Django

前端 未结 2 416
时光取名叫无心
时光取名叫无心 2021-02-05 03:25

Given the following model with two many-to-many relations:

class Child(models.Model):
    name = models.CharField(max_length=80)

class Foo(models.Model):
    ba         


        
2条回答
  •  春和景丽
    2021-02-05 03:58

    You haven't read Django's documentation carefully enough. Here it says:

    If you have more than one ManyToManyField pointing to the same model and want to suppress the backwards relations, set each related_name to a unique value ending with '+'.

    The related_name attributes have to be unique, not the same.

提交回复
热议问题