Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7878387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:38:41+00:00 2026-06-03T03:38:41+00:00

Ok, so I would like some advice on how to set up a model.

  • 0

Ok, so I would like some advice on how to set up a model. I have a recipe model I’m developing (plan on putting a tablet in the kitchen). What I would like to be able to do is have each recipe have an ingredients list, but also have a corresponding quantity list that matches up to the ingredient list. The idea is that I have an Ingredient model that will be used to keep track of what ingredients I have on hand and how much, and the Recipe model will have it’s own ingredients list as well as what quantities are needed. That way I could have the app show recipes that I have ingredients to make, and hide ones I don’t have ingredients to (or actually it will be more elaborate but that’s the idea). Here’s my current setup:

Ingredient model.py

class Unit_of_Measure(models.Model):

   """Unit_of_Measure model. This is used as the foriegnkey for the Quantity model unit_of_measure key."""

   class Meta:
           verbose_name_plural = "Units of Measure"

   def __unicode__(self):
           return self.unit_of_measure

   unit_of_measure = models.CharField(max_length=200)

class Location(models.Model):

   """Location model. This is used a the foriegnkey for the Ingredient model location key."""

   class Meta:
           verbose_name_plural = "Locations"

   def __unicode__(self):
           return self.place

   place = models.CharField(max_length=200)

class Ingredient(models.Model):

   """Ingredients model. Includes ingredient title, quantity on hand, location of ingredient (foreignkey), expiration date, and if it is a shop for ingrdient."""

   class Meta:
           verbose_name_plural = "Ingredients"

   def __unicode__(self):
           return self.title

   title = models.CharField(max_length=200)
   quantity = models.CharField(max_length=200)
   unit_of_measure = models.ForeignKey(Unit_of_Measure)
   location = models.ForeignKey(Location)
   expiration_date = models.DateTimeField()
   shop_for = models.BooleanField()

Recipe model.py

class RecipeType(models.Model):

   """Recipe type model. This is used as the foreign key for the Recipe model recipe style."""

   def __unicode__(self):
           return self.style

   style = models.CharField(max_length=200)

class Recipe(models.Model):

   """Recipe model. Includes recipe title, recipe style (dinner, snack, etc..), ingredient list (foreignkey), recipe instructions, storage style, and expiration date."""

   class Meta:
           verbose_name_plural = "Recipes"

   def __unicode__(self):
           return self.title

   title = models.CharField(max_length=200)
   style = models.ForeignKey(RecipeType)
   required_ingredient_list = models.ManyToManyField(Ingredient, related_name='additional_ingredient_list')
   additional_ingredient_list = models.ManyToManyField(Ingredient, related_name='required_ingredient_list', blank=True)
   recipe_instruction = models.TextField()
   storage_style = models.CharField(max_length=200)
   expiration_date = models.DateTimeField()

So any suggestion as to how to match up two field lists? like “required_ingredient_list” matching up to “required_ingredient_quantity_list” or something? Or a better solution? Or any suggestions in general? Right now I can sort recipes by ingredients but since the Ingredient model’s quantity is quantity I have on hand in my kitchen, I don’t really have a field to represent the quantities the recipe uses, it just gets said in the recipe_instruction field. Halpz!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:38:43+00:00Added an answer on June 3, 2026 at 3:38 am

    Use a “through model” to link Recipes to Ingredients. The intermediate model could then have an associated unit and a numeric or string measure associated with that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to the MVVM model, so I would like some advice, the
I would like some advice on the best approach to use in the following
I am designing RESTful Api's and would like some advice on designing an API
I am considering starting an OSS project and would like some advice. I would
I'm looking into building a distributed application and would like some advice on the
i am new to java, and would like some advice on the following i
I would like some of my preferences to have icons, like the Settings app.
I am developing a site and i would like some simple markup. I would
I'm learning Clojure and would like some advice on idiomatic usage. As part of
I would like some advice on safe ways to deal with struct's when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.