Advertisement
horozov86

2.Menu

Nov 22nd, 2023 (edited)
745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. def validate_menu_categories(value):
  2.     required_catogories = ["Appetizers", "Main Course", "Desserts"]
  3.     for c in required_catogories:
  4.         if c.lower() not in value.lower():
  5.             raise ValidationError(message "The menu must include each of the categories "Appetizers", "Main Course", "Desserts".")
  6.    
  7.        
  8. class Menu(models.Model):
  9.     name = models.CharField(max_length=100)
  10.     description = models.TextField(validators=[validate_menu_categories])
  11.     restaurant = models.ForeignKey("Restaurant", on_delete=models.CASCADE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement