Help with model

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?

I’m not sure I understand what the requirements are here.

What I think I’m getting from this is that you have some inventory of items in Stock. You may have any number of any individual item - the number of that item are stored in aantal

Each entry in Verhuur represents a window of time where some quantity of that item is not going to be available.

This all make sense, and I think I’m on track so far.

What I don’t understand is what is it that you’re looking for assistance to do. What do you mean by “create bundles of these hireable objects” and “specify how much of each object gets hired”?

Side note: I see where you’ve separated the begin and end dates in to separate date and time fields. Generally speaking, this is a mistake. If you’re going to want to create a query to check windows of time, you definitely want to have these as a DateTimeField. You can still allow entry for this as separate elements, then combine the values in the form (or view), but trying to write proper queries for these separated fields is extremely intricate and very easily prone to error.