So, I’m creating a room renting project. The renting is not for a whole day, it’s only for 2 hours. I’m gonna have several renting companies each having several rooms for rent with diffrent capacity. So, my question is, if a room is rented on lets say 25/03/2022 20:00(so its gonna be unvailable until 22:00, and also unavailable 2 hours prior), I want the room to be still visible on the site, because someone maybe will want to rent it on diffrent day or the same day in diffrent hour. How to make this exact room unavailable only on this date and this hours? If I make is_available row in the model its gonna switch to False whenever someone rent it, but I want it to be available for all the other days and hours. Here are the models:
class Owner(models.Model):
name = models.CharField(max_length=100)
address = models.TextField()
phone = models.PositiveIntegerField()
class Room(models.Model):
number = models.CharField(max_length=100)
owner = models.ForeignKey(Owner, on_delete=models.CASCADE)
capacity = models.PositiveIntegerField()
is_available = models.BooleanField(default=True)
class reservation(models.Model):
room_number = models.ForeignKey(Room)
guest_name = models.CharField(max_length=200)
guests = models.PositiveIntegerField()
date_reserved = models.DateTimeField()