📜  如何逐步使用 django 制作预订网站 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:46.066000             🧑  作者: Mango

代码示例1
# models.py

Class Customer(models.Model):
     email = models.EmailField()
     # And whatever other custom fields here; maybe make a ForeignKey link to User? Whatever.

Class Table(models.Model):
     seats = models.IntegerField()
     min_people = models.IntegerField()
     max_people = models.IntegerField()

Class Reservation(models.Model):
     table = models.ForeignKey('Table', on_delete=Models.CASCADE)
     party = models.ForeignKey('Customer', on_delete=Models.CASCADE)
     spot = models.DateField()
     # Make sure you don't use 'time' for this field, as that will cause a headache later on.