Beispiel #1
0
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')})
Beispiel #2
0
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')})