added recipe images

This commit is contained in:
vabene1111
2019-12-25 16:46:16 +01:00
parent e2301c0c3a
commit 3cb01d6332
10 changed files with 65 additions and 8 deletions

View File

@ -40,13 +40,18 @@ def internal_recipe_update(request, pk):
recipe_instance = get_object_or_404(Recipe, pk=pk)
if request.method == "POST":
form = InternalRecipeForm(request.POST)
form = InternalRecipeForm(request.POST, request.FILES)
if form.is_valid():
recipe = recipe_instance
recipe.name = form.cleaned_data['name']
recipe.instructions = form.cleaned_data['instructions']
recipe.time = form.cleaned_data['time']
if form.cleaned_data['image']:
recipe.image = form.cleaned_data['image']
else:
recipe.image = None
recipe.save()
form_ingredients = json.loads(form.data['ingredients'])