开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜