Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ReviewMixin(models.Model):
- review_content = models.TextField()
- rating = models.PositiveIntegerField(validators=[validators.MaxValueValidator(5)])
- class Meta:
- ordering = ["-rating"]
- class RestaurantReview(ReviewMixin):
- reviewer_name = models.CharField(max_length=100)
- restaurant = models.ForeignKey("Restaurant", on_delete=models.CASCADE)
- class Meta:
- abstract = True
- verbose_name = "Restaurant Review"
- verbose_name_plural = "Restaurant Reviews"
- unique_together = ["reviewer_name", "restaurant"]
- class RegularRestaurantReview(RestaurantReview):
- pass
- class FoodCriticRestaurantReview(RestaurantReview):
- food_critic_cuisine_area = models.CharField(max_length=100)
- class Meta:
- ordering = ["-rating"]
- verbose_name = "Food Critic Review"
- verbose_name_plural = "Food Critic Reviews"
- unique_together = ["reviewer_name", "restaurant"]
- class MenuReview(ReviewMixin):
- reviewer_name = models.CharField(max_length=100)
- menu = models.ForeignKey("Menu", on_delete=models.CASCADE)
- class Meta:
- verbose_name = "Menu Review"
- verbose_name_plural = "Menu Reviews"
- unique_together = ["reviewer_name", "menu"]
- indexes = [models.Index(field=['menu'], name="main_app_menu_review_menu_id")]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement