我有Django模型如下:
class UserBusinessUnit(models.Model):
company = models.ForeignKey(to=Company, limit_choices_to={'is_dealership': True})
user = models.ForeignKey(to=User)
brands = models.ManyToManyField(to=Brand)
business_unit = models.ForeignKey(to=BusinessUnit)
active = models.BooleanField(default=True)
class Meta:
ordering = ('user__username',)
def __unicode__(self):
return self.user.email + ' - ' + self.business_unit.name
在Django管理面板中,它看起来像这样:
我希望能够根据User
字段填充Business unit
和Company
字段。
因此,如果我更改company
字段,我希望立即填充User
和Business
字段。
知道怎么做吗?