Example #1
0
def edit_printer(request, id):
    instance = get_object_or_404(Printer, id=id)
    form = PrinterForm(request.POST or None, instance=instance)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect('/')   
    return render(request, 'inv_app/additem.html', {'form': form})
Example #2
0
def add_printer(request):
    if request.method == 'POST': 
        printer_form = PrinterForm(request.POST)
        if printer_form.is_valid(): 
            printer_form.save()
            return HttpResponseRedirect('') # Redirect after POST
    else:
        printer_form = PrinterForm() # An unbound form

    return render(request, 'inv_app/additem.html', {
        'form': printer_form,
    })