I have a Stock model which is basically a database with objects currently in my stock, one of it’s attributes is a boolean to tell if the object is hireable.
class Stock(models.Model):
voorwerp = models.CharField(max_length=45, null=True)
aantal = models.IntegerField()
rek = models.ForeignKey(Rekken, on_delete=models.SET_NULL, default="-------", null=True)
schap = models.ForeignKey(Schappen, on_delete=models.SET_NULL, default="-------", null=True)
categorie = models.ForeignKey(Categorien, on_delete=models.SET_NULL, default="-------", null=True)
verhuurbaar = models.BooleanField(null=True, verbose_name="Verhuurbaar?")
merk = models.CharField(max_length=45, null=True, blank=True)
maat = models.CharField(max_length=200, null=True, verbose_name="Maat in bv. cm, cl, XL, ...", blank=True)
class Meta:
ordering = ["voorwerp"]
def __str__(self):
return self.voorwerp
Then I have an other model called Verhuren which basically saves data of when a hireable object is hired to who, which date, the amount etc. It uses a foreign key to from the Stock model.
class Verhuur(models.Model):
voorwerp = models.CharField(max_length=45, null=True)
begindatum = models.DateField()
einddatum = models.DateField()
beginuur = models.TimeField()
einduur = models.TimeField()
aantal = models.IntegerField()
huurder = models.CharField(max_length=45, null=True)
calendarid = models.CharField(max_length=45, null=True, blank=True)
class Meta:
ordering = ["voorwerp"]
def __str__(self):
return self.voorwerp
The thing is I also want to be able to create bundles of these hireable objects and specificly specify how much of each object ets hired. This is the part where I struggle. I don’t seem to find a way to make this work. ANybody any ideas?