This commit is contained in:
Benjamin 2023-03-06 17:49:57 +01:00
parent a78be3378b
commit ebd397f351

View file

@ -123,7 +123,7 @@ def edit_version(request, slug_recipe, slug_version):
recipe = get_object_or_404(Recipe, slug=slug_recipe) recipe = get_object_or_404(Recipe, slug=slug_recipe)
version = get_object_or_404(Version, recipe=recipe, slug=slug_version) version = get_object_or_404(Version, recipe=recipe, slug=slug_version)
if request.method == 'POST': # TODO refactor with add_version if request.method == 'POST':
version_form = VersionForm(request.POST, prefix=VERSION_FORM_PREFIX, instance=version, author_placeholder=get_name_of_user(request.user)) version_form = VersionForm(request.POST, prefix=VERSION_FORM_PREFIX, instance=version, author_placeholder=get_name_of_user(request.user))
ingredients_formset = IngredientFormSet(request.POST, queryset=version.ingredients.all(), prefix=INGREDIENTS_FORMSET_PREFIX) # type: ignore ingredients_formset = IngredientFormSet(request.POST, queryset=version.ingredients.all(), prefix=INGREDIENTS_FORMSET_PREFIX) # type: ignore
version_form.recipe_id = recipe.id # type: ignore version_form.recipe_id = recipe.id # type: ignore