0

模型.py

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)

怀疑

我想如何将食物和服务与餐厅模式结合起来,并且也能够对它们进行评分,请帮助,在此先感谢

4

1 回答 1

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)

于 2012-08-24T16:09:18.350 回答