Hotel/hotel/rooms/models.py

28 lines
591 B
Python

from django.db import models
from django.core.validators import MinValueValidator
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)
reserved = models.BooleanField()