在models.py中,有2个模型
__ _ __ _ __ _ __ _ _ AAA _ __ _ __ _ __ _ __ _ __ _ ___
class AAA(models.Model):
city = models.CharField(max_length=255,primary_key=True)
province = models.CharField(max_length=255)
def __unicode__(self):
return self.city
__ _ __ _ __ _ __ _ _ BBB _ __ _ __ _ __ _ __ _ ___
class BBB(models.Model):
city = models.ForeignKey(AAA)
# other columns we don't care
def __unicode__(self):
return self.city
__ _ __ _ __ _ ___我想做什么_ __ _ __ _ __ _ __ _ ___
在管理框架中,当你在“BBB”表中“添加”一条记录时,必须从“AAA”表中选择一个存在的“城市”,当这个动作id完成后,我希望添加页面可以显示相应的“省”提醒用户当前城市属于哪个省。(你可以在添加页面中设置一个临时字段,而不是在模型BBB中,我不希望数据冗余)