Exemplo n.º 1
0
def edit_network(request, id):
    instance = get_object_or_404(Printer, id=id)
    form = NetworkForm(request.POST or None, instance=instance)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect('/')   
    return render(request, 'inv_app/additem.html', {'form': form})
Exemplo n.º 2
0
def add_network(request):
    if request.method == 'POST': 
        network_form = NetworkForm(request.POST)
        if network_form.is_valid(): 
            network_form.save()
            return HttpResponseRedirect('') # Redirect after POST
    else:
        network_form = NetworkForm() # An unbound form

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