def hotelNuevo(request): if request.method == "POST": form = HotelForm(request.POST) if form.is_valid(): hotel = form.save() hotel.save() return redirect('hoteles.views.hoteles') else: form = HotelForm() return render(request, 'hoteles/hotel_edit.html',{'form':form,'nuevo':'Nuevo'})
def hotelEditar(request, pk): hotel = get_object_or_404(DatosHotel, pk=pk) if request.method == "POST": form = HotelForm(request.POST, instance=hotel) if form.is_valid(): hotel = form.save() hotel.save() return redirect('hoteles.views.hoteles') else: form = HotelForm(instance=hotel) return render(request, 'hoteles/hotel_edit.html',{'form':form, 'nuevo':'Actualizar'})