models.py
class dummy(models.Model):
GEOTYPE_CHOICES = (
(u'1', u'country'),
(u'2', u'state'),
(u'3', u'district'),
(u'4', u'pincode'))
geoType = models.CharField(max_length=9, choices=GEOTYPE_CHOICES)
if geoType==1:
geoId = models.ForeignKey(CountryMaster,null=True,blank=True,on_delete=models.CASCADE)
elif geoType==2:
geoId = models.ForeignKey(StateMaster,null=True,blank=True,on_delete=models.CASCADE)
elif geoType==3:
geoId = models.ForeignKey(DistrictMaster,null=True,blank=True,on_delete=models.CASCADE)
else:
geoId = models.ForeignKey(PincodeMaster,null=True,blank=True,on_delete=models.CASCADE)
如果用户将geotype设置为2,则已经在geoId中调用了statemaster。但是在迁移时,我无法在数据库中注册geoId。
对此的任何指点都会有很大帮助。提前致谢。