I have declared my model classes as found in this link....I now want to customize how my add/edit ModelForm for a Vehicle
object is rendered in that I want the year, make, model, and manufacturer fields开发者_JAVA技巧 to be rendered separately as opposed to referring to the one common_vehicle
field from the Vehicle
class. How can this be done?
Why don't you make Vehicle inherit CommonVehicle? (Depending on why you've got that FK there, of course -- you may really need it, but I'm guessing not)
Instead of:
class Vehicle(models.Model):
...
common_vehicle = models.ForeignKey(CommonVehicle)
Use:
class Vehicle(CommonVehicle):
...all your other Vehicle fields here, but not the FK to CommonVehicle
精彩评论