def edita_platillo(request, id_platillo): formBuscar = BusquedaForm() Qdatos = Platillo.objects.get(pk = id_platillo) if request.method == 'POST': form = PlatilloForm(request.POST, request.FILES, instance = Qdatos) if form.is_valid(): form.save() return HttpResponseRedirect('/mi-negocio/platillos/') else: form = PlatilloForm(instance = Qdatos) return render_to_response('panel/platillo.html', { 'formulario': formBuscar, 'form': form }, context_instance = RequestContext(request))
def nuevo_platillo(request): formBuscar = BusquedaForm() if request.method == 'POST': empresa = Empresa.objects.get(usuario = request.user) platillo = Platillo(empresa = empresa) form = PlatilloForm(request.POST, request.FILES, instance = platillo) if form.is_valid(): form.save() return HttpResponseRedirect('/mi-negocio/platillos/') else: form = PlatilloForm() return render_to_response('panel/platillo.html', { 'formulario': formBuscar, 'form': form }, context_instance = RequestContext(request))