def get(self, request, pk=None): x = get_object_or_404(Recipe, id=pk, owner=self.request.user) form = CreateForm(instance=x) # x = Recipe.objects.get(id=pk) ingredients = Ingredient.objects.filter(recipe=x).order_by('-created_at') ingredient_form = IngredientForm() context = {'recipe':x, 'ingredients':ingredients, 'ingredient_form':ingredient_form, 'form': form} return render(request, self.template_name, context)