class Restaurant(models.Model):
#fields here
class Food(models.Model):
rating = RatingField(range=5, weight=5,can_change_vote = True,allow_delete = True,allow_anonymous = True)
restaurant = models.OneToOneField(Restaurant)
class Service(models.Model):
rating = RatingField(range=5, weight=5,can_change_vote = True,allow_delete = True,allow_anonymous = True)
restaurant = models.OneToOneField(Restaurant)
我想如何整合食物和服务以及餐厅模型,并且还可以评价它们,请帮助,提前谢谢
答案 0 :(得分:1)
而不是:
class Restaurant(models.Model):
#fields here
class Food(models.Model):
rating = RatingField(range=5, weight=5,can_change_vote = True,allow_delete = True,allow_anonymous = True)
restaurant = models.OneToOneField(Restaurant)
class Service(models.Model):
rating = RatingField(range=5, weight=5,can_change_vote = True,allow_delete = True,allow_anonymous = True)
restaurant = models.OneToOneField(Restaurant)
尝试:
class Restaurant(models.Model):
#fields here
food_rating = RatingField(range=5, weight=5,can_change_vote = True,allow_delete = True,allow_anonymous = True)
service_rating = RatingField(range=5, weight=5,can_change_vote = True,allow_delete = True,allow_anonymous = True)