My first question here, I've been looking around but couldn't find a solution.
I am building a reservation system, my models are
class Room(models.Model):
number = models.IntegerField()
beds = models.IntegerField()
capacity = models.IntegerField()
category = models.ForeignKey(
RoomCategory, on_delete=models.CASCADE, blank=True, null=True)
class Booking(models.Model):
room = models.ForeignKey(Room, on_delete=models.CASCADE, blank=True, null=True)
check_in = models.DateField()
check_out = models.DateField()
status = models.IntegerField(blank=True, null=True)
if request.method == 'POST':
no_disponible = "No hay habitaciones disponibles, selecciona otras fechas"
if form.is_valid():
room_list = Room.objects.filter(category=1).exclude(booking__check_in__lt=form.cleaned_data['check_out'],
booking__check_out__gt=form.cleaned_data['check_in'], booking__status__gt=0)
I am changing status when the customer confirms so I want to check if dates are available when status is not 1 (I change status to 1 once the payment is approved. However booking__status__gt=0 doesn't seem to work here