Question

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)

doubt

how am i suppose to integrate the food and service along with the restaurant model and also be able to rate them aswell , please help , thanks in advance

Was it helpful?

Solution

Instead of:

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)

Try:

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top