我在this link....I中声明了我的模型类,现在我想定制Vehicle对象的添加/编辑ModelForm的呈现方式,因为我希望分别呈现year、make、model和make字段,而不是引用Vehicle类中的一个common_vehicle字段。如何做到这一点?
发布于 2010-05-14 17:30:57
为什么不让Vehicle继承CommonVehicle呢?(当然,这取决于你为什么要把FK放在那里--你可能真的需要它,但我猜不是)
而不是:
class Vehicle(models.Model):
...
common_vehicle = models.ForeignKey(CommonVehicle)使用:
class Vehicle(CommonVehicle):
...all your other Vehicle fields here, but not the FK to CommonVehiclehttps://stackoverflow.com/questions/2832986
复制相似问题