Найти - Пользователи
Полная версия: Можно ли в модели создать 2 поля ForeignKey к одной модели.
Начало » Django » Можно ли в модели создать 2 поля ForeignKey к одной модели.
1
slepov
Можно ли в модели создать 2 поля ForeignKey к одной модели?

Делаю:
class Affiliates(models.Model):
    master = models.ForeignKey(Firm)
    slave = models.ForeignKey(Firm)

Выдаёт ошибку:

core.Affiliates.master: (fields.E304) Reverse accessor for 'Affiliates.master' clashes with reverse accessor for 'Affiliates.slave'.
        HINT: Add or change a related_name argument to the definition for 'Affiliates.master' or 'Affiliates.slave'
TroSer
slepov
Можно ли в модели создать 2 поля ForeignKey к одной модели?
можно
просто делайте, что сказано в сообщении
slepov
Add or change a related_name argument to the definition
тыц
slepov
Спасибо, помогло.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB