Esempio n. 1
0
def agregar(request):
	if request.method == "POST":
		form = PeliculasForm(request.POST)
		print request.POST
		if form.is_valid():
			pelicula = form.save()
			pelicula.save()
			return redirect('Peliculas.views.listar')
	else:
		form = PeliculasForm
	return render(request,'Peliculas/pelicula_nueva.html',{'form':form, 'etiqueta':'Nueva'})
Esempio n. 2
0
def editar(request, pk):
	peliculas = get_object_or_404(Peliculas, pk = pk)
	if request.method == "POST":
		form = PeliculasForm(request.POST, instance = peliculas)
		print request.POST
		if form.is_valid():
			peliculas = form.save()
			peliculas.save()
			return redirect('lista')
	else:
		form = PeliculasForm (instance=peliculas)
	return render(request,'Peliculas/pelicula_nueva.html',{'form':form, 'etiqueta':'Actualizar'})