I have a model, which contains some fields, based on the one of the field value in the model, we need to create n number of objects in another model with default values.
I have a model called Room and it contains a field called number_of_beds based on that field we need to create n number of objects in anothe model called Bed.
Room(models.Model):
room_no = IntegerField(primary_key=True,unique=True)
number_of_beds = IntegerField()
'''
and so on
'''
Bed(models.Model):
room_no = models.ForeignKey('Room', on_delete=models.SET_NULL, null=True)
bed_no = models.IntegerField(blank=True,default='Increment value')
'''
and so on
'''
if number_of_beds =2, need to create two objects in Bed with default values under the same ForeignKey.
Any help would be appreciated.
number_of_beds? to large or to small number