On edit data from inlineformset_factory is missing
This is my code to get recipe data
objRecipe = models.Recipe.objects.get(id=recipe_id)
recipe = models.RecipeForm(instance=objRecipe)
objRecipeSteps = models.RecipeStep.objects.filter(recipe__id = objRecipe.id)
recipeSteps = models.RecipeStepFormSet(queryset=objRecipeSteps)
I am able to display data from "recipe" but not from "recipeSteps".
This is my template code
{{ recipeSteps.manag开发者_如何转开发ement_form }}
{% for form in recipeSteps.forms %}
<div class="form-row">
<span class="label">
<span class="step-add"><a href="#">Add</a></span>
<span class="step-remove"><a href="#">Remove</a></span>
</span>
{{ form.recipe_step }}
</div>
{% endfor %}
I couldn't find anything here http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#inline-formsets
Well, your link explains what to do. Instead of passing a queryset, pass the instance
parameter, which is the Recipe object.
recipeSteps = models.RecipeStepFormSet(instance=objRecipe)
精彩评论