python - django frontend inline form for ManyToMany displayed as table with add option -


i need way add (and edit) elements (connected m2m) in frontend (not admin) form.

my models:

class ingredientname(models.model):         name = models.charfield(_('name of ingredient'), max_length=255)  class unit(models.model):         name = models.charfield(_('unit name'), unique=true, max_length=255)  class ingredient(models.model):         name = models.foreignkey(ingredientname)         unit = models.foreignkey(unit)         value = models.floatfield()  class recipe(models.model):         title = models.charfield(_('title'), max_length=250)         portions = models.positiveintegerfield(_('portions'))         ingredients = models.manytomanyfield(ingredient)         description = models.textfield(_('description'))  forms:      class recipeform(modelform):         class meta:             model = recipe 

views:

class addrecipe(createview):     form_class = recipeform 

in first step i've tried use ingredientformset = inlineformset_factory(ingredient,recipe, form=recipeform) got error:

<class 'recipe.models.recipe'> has no foreignkey <class 'recipe.models.ingredient'> 

whats best, , reusable way, this? widget exist this?


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -