Exemplo n.º 1
0
def create(request):
	#when POST
	if request.method == 'POST':
		form = AlmacenadoForm(request.POST)
		if form.is_valid():
			form.save()
		return HttpResponseRedirect('/almacen/')
	else:
		form = AlmacenadoForm()
	return render_to_response('almacen/detail.html', {'form':form}, context_instance=RequestContext(request))
Exemplo n.º 2
0
def update(request, id, id_producto = None):
	instance = None
	if id is not None:
		instance = Almacenado.objects.get(id = id)
	if request.method == 'POST':
		form = AlmacenadoForm(request.POST, instance = instance)
		if form.is_valid():
			form.save()
			return HttpResponseRedirect('/almacen')
	else:
		form = AlmacenadoForm(instance = instance)
	return render_to_response('common/detail.html',{'form':form}, context_instance = RequestContext(request))