I am writing a movie about Seat Booking Django App, I can not conceive of a simple model.
First of all, here are my current models:
from django.db import models from django.contrib.auth import get_user_model class Seats(models.Model): seat_choice = ( ('AA', 'AA'), ('AB', 'AB'), ('BA', 'BA'), ('BB', 'BB'), ('CA', 'CA'), ('CB', 'CB') ) name = models.CharField(choices=seat_choice, max_length=2) def __str__(self): return self.name class Booking(models.Model): hall = models.OneToOneField(Seats) user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
I wish that a user could buy / reserve one or more seats, but the same user or another user can not buy a seat already reserved by someone or by himself.
But the problem is that my current models do not work as I want …
Currently, it works as if a user bought a ticket, the same user could not buy the ticket that he had already bought! but the problem is, now another user can buy the ticket already booked by someone a and I do not want that at all.
I want that if a place has already been booked by someone, no one can book it later, but it can be canceled by the user who has reserved!
Can someone help me to achieve this?