Advertisement
horozov86

4. Restaurant Review Types

Nov 22nd, 2023
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. class RestaurantReview(models.Model):
  2.     reviewer_name = models.CharField(max_length=100)
  3.     restaurant = models.ForeignKey("Restaurant", on_delete=models.CASCADE)
  4.     review_content = models.TextField()
  5.     rating = models.PositiveIntegerField(validators=[validators.MaxValueValidator(5)])
  6.    
  7.     class Meta:
  8.         abstract = True
  9.         ordering = ["-rating"]
  10.         verbose_name = "Restaurant Review"
  11.         verbose_name_plural = "Restaurant Reviews"
  12.         unique_together = ["reviewer_name", "restaurant"]
  13.        
  14.        
  15. class RegularRestaurantReview(RestaurantReview):
  16.     pass
  17.  
  18.  
  19. class FoodCriticRestaurantReview(RestaurantReview):
  20.     food_critic_cuisine_area = models.CharField(max_length=100)
  21.    
  22.     class Meta:
  23.         ordering = ["-rating"]
  24.         verbose_name = "Food Critic Review"
  25.         verbose_name_plural = "Food Critic Reviews"
  26.         unique_together = ["reviewer_name", "restaurant"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement