我刚刚完成了类似的项目,我猜你的解决方案是:
class InstrumentEquipmentType(models.Model): manufacturer_model_type = models.ForeignKey(InstrumentModelType) instrument_manufacturer = ChainedForeignKey(InstrumentManufactuer, chained_field='instrument_model_type', chained_model_field='manufacturer_model_type', auto_choose = True, show_all = False) equipment_type = models.CharField(max_length=100) def __unicode__(self): # Python 3: def __str__(self): return unicode(self.equipment_type)
如果向我发送我的例子,请告诉我
试试Django Clever Selects
https://github.com/PragmaticMates/django-clever-selects
我在我的Django 1.6项目中使用它。在视图和表单中操作链(在巧妙选择中)更有用,而不是在模型中(如智能选择)。