Answer the question
In order to leave comments, you need to log in
How to bind Django models for a hotel site?
Good afternoon everyone! I am new to Django. I'm making a hotel website for myself, I'm stuck on compiling models.
Task: in the admin panel, it is necessary to separately specify the date periods (from / to) (to indicate the prices for the rooms), they are the same for all rooms. Then I go to any room, I see these periods there, I put down the prices.
I can’t figure out how to link these classes (ForeignKey or ManyToManyField) and then display these periods in the admin panel in the numbers.
I would be very grateful for help in this matter in "understandable" language.
class Nomera (models.Model):
name = models.CharField('Название', max_length=50)
description = models.TextField('Описание')
mest = models.IntegerField('Кол-во мест', choices=SEATS, default=2)
class Period (models.Model):
startDate = models.DateField('c')
endDate = models.DateField('по')
class Prices (models.Model):
price = models.IntegerField('Цена')
period = models.ForeignKey(Period, on_delete=models.CASCADE)
nomer = models.ForeignKey(Nomera, on_delete=models.CASCADE)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question