예제 #1
0
파일: views.py 프로젝트: kevincullinane/inv
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})
예제 #2
0
파일: views.py 프로젝트: kevincullinane/inv
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,
    })