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})
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, })