from django.db import models from django.core.validators import MinValueValidator, RegexValidator class RoomType(models.Model): room_type = models.CharField(max_length=40) def __str__(self): return self.room_type class Room(models.Model): room_number = models.IntegerField( primary_key=True, validators=[ MinValueValidator(1) ] ) price = models.IntegerField( validators=[ MinValueValidator(1) ] ) room_type = models.ForeignKey(RoomType, on_delete=models.CASCADE) def __str__(self): return str(self.room_number) class Client(models.Model): id_number = models.CharField(max_length=9, primary_key=True) name = models.CharField(max_length=40) surname = models.CharField(max_length=40) def __str__(self): return self.name + self.surname class Reservation(models.Model): room_number = models.ForeignKey(Room, on_delete=models.CASCADE) client_id = models.ForeignKey(Client, on_delete=models.CASCADE) begin_date = models.DateField() end_date = models.DateField()