Skip to content

Instantly share code, notes, and snippets.

@joshkehn
Created June 26, 2013 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshkehn/5869468 to your computer and use it in GitHub Desktop.
Save joshkehn/5869468 to your computer and use it in GitHub Desktop.
Ingredient and Meal models (Django)
class Ingredient (models.Model):
"""Describes an ingredient for meals. This ingredient contains specific
diet and food preference information and can be attached to multiple meals."""
name = models.CharField(max_length=255)
franchise = models.ForeignKey(Franchise)
diets = models.ManyToManyField(Diet, null=True, blank=True, verbose_name="special diets or food allergies")
preferences = models.ManyToManyField(FoodPreference, null=True, blank=True)
class Meal (NutritionCapable, PricedModel, DatedModel):
"""Basic object representing a meal. NutritionCapable, PricedModel,
and DatedModel all come from a utility class that adds fields for
nutrition information, pricing information, and created/updated auto
fields."""
name = models.CharField(max_length=255)
mc = models.ManyToManyField(MC, verbose_name="Menu Category")
ingredients = models.ManyToManyField(Ingredient)
def __uncode__ (self):
return unicode(self.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment