예제 #1
0
파일: views.py 프로젝트: abelthf/crud_ok
def agregar_producto(request):
	if request.method == "POST":
		formulario = ProductoForm(request.POST)
		if formulario.is_valid():
			formulario.save()
			return HttpResponseRedirect("/")
	else:
		formulario = ProductoForm()
	return render_to_response("agregar_productos.html", {"formulario":formulario}, context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: abelthf/crud_ok
def editar_producto(request, id_producto):
	producto = Producto.objects.get(pk=id_producto)
	if request.method == "POST":
		formulario = ProductoForm(request.POST, instance=producto)
		if formulario.is_valid():
			formulario.save()
			return HttpResponseRedirect("/")
	else:
		formulario = ProductoForm(instance=producto)

	return render_to_response("editar_producto.html", {"formulario": formulario}, context_instance=RequestContext(request))