Код: Выделить всё
Class Bank(models.Model):
customers = models.ManyToManyField(Customer,'banks', through='bank_customer')
Class Customer(models.Model):
name = models.CharField(max_length=50)
Class Bank_customer(models.Model):
customer = models.ForeignKey(Customer,on_delete=models.CASCADE)
bank = models.ForeignKey(Bank,on_delete=models.CASCADE)
city = models.ForeignKey(City,on_delete=models.CASCADE)
Class City(models.Model):
name = models.CharField(max_length=100)
Код: Выделить всё
bank.customers.add(customer)
Подробнее здесь: https://stackoverflow.com/questions/631 ... jango-many