def blender_add(request): if request.method == 'POST': form = BlenderForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('blenders')) else: form = BlenderForm() return render(request, 'add.html', {'form': form, 'cancel': reverse('blenders')})
def blender_index(request, blender_id): blender = get_object_or_404(Blenderrr, id=blender_id) if request.method == 'POST': form = BlenderForm(request.POST, instance=blender) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('blenders')) else: form = BlenderForm(instance=blender) return render(request, 'add.html', {'form': form, 'cancel': reverse('blenders')})