django评分以及一对一字段



models.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)

怀疑

我该如何将食物和服务与餐厅模式相结合,并对其进行评分,请帮忙,提前感谢

代替:

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)

KISS

相关内容

  • 没有找到相关文章

最新更新