I want to be able to add in new Ingredients from the /admin section of
Django instead of supplying it as a tuple hardcoded into my model.
When I create a Recipe, I need to have a series of rows below the
title, description, first, last name, and pub_date section where I can
select an Ingredient from a dropdown list and then to the right of the
ingredient needs to be an CharField where I input how much of each
component I need to add for that particular recipe. It would look
like:
Ingredient 1 2 tsp
Ingredient 2 1/2 cup
...
Each row starting with that Ingredient dropdown list followed by a CharField.
Any help on hooking this functionality into the model would be
*greatly* appreciated. Thanks!
Shane
In your recipe model.
If you want a pretty interface in admin (if you're not using newforms-
admin) then:
ingredients = models.ManyToManyField('Ingredient',
filter_interface=models.HORIZONTAL)
Not sure if this is the best way, but it works for me: http://dpaste.com/15913/
Basically ingredients like chicken, onions, etc are going to be in
lots of recipes but the quantity will be different in each. So make
one model for each type of ingredient, and another model to combine an
ingredient and a quantity. Then use edit_inline to make it convenient
to edit in the admin.
Shane
Shane
--
Shane ∞ http://liquid.homelinux.org
---------
Bender: "Amy, you like cute things so I baked you a pony."
---------
http://www.reefs.org - Where reefkeeping begins on the internet.
http://www.advancedaquarist.com - High quality, free monthly publication for
the reef keeping hobbyist.
http://www.aquaristcourses.org - Distance learning courses for the
marine aquarist.