Assume that I have the following models defined in the DEGENGO (not tested):
class caramaker (Models.Model): name = models.CharField ( "Car maker's name", max_length = 40) class car (models.Model): car_id = models.IntegerField ("ID for this particular car") Producer = Model. ForeignKey ("Manufacturer of this car")
Is there a standard way to ensure that all cars s is with the same manufacturer all car s For example create unique car_id , without car_id two car makers, "Skoda" and "Renault" are created by Skoda 400 cars 300 car created by s and Renault, I want to make sure that car_id is unique to all Škoda, and is unique to all the rnnist but all cars s Thank you
Model option Unique_togethe R . See Django Docs: Class car (models.Model): car_id = model.tegerfield ("ID for this particular car") manufacturer = model. Forvinki ("Manufacturer of this car") Category Meta (object): unique_toggler = ("car_id", "creator")
Comments
Post a Comment