def edita_sucursal(request, id_sucursal): formBuscar = BusquedaForm() Qdatos = Sucursal.objects.get(pk = id_sucursal) if request.method == 'POST': form = SucursalForm(request.POST, instance = Qdatos) if form.is_valid(): form.save() return HttpResponseRedirect('/mi-negocio/sucursales') else: form = SucursalForm(instance = Qdatos) return render_to_response('panel/sucursal.html', { 'formulario': formBuscar, 'form': form }, context_instance = RequestContext(request))
def datos_sucursal(request): formBuscar = BusquedaForm() if request.method == 'POST': empresa = Empresa.objects.get(usuario = request.user) sucursal = Sucursal(empresa = empresa) form = SucursalForm(request.POST, instance = sucursal) if form.is_valid(): form.save() return HttpResponseRedirect('/mi-negocio/sucursales') else: form = SucursalForm() return render_to_response('panel/sucursal.html', { 'formulario': formBuscar, 'form': form }, context_instance = RequestContext(request))
def get_sucursal(request): if request.method == 'POST': form = SucursalForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/inicio') else: form = SucursalForm() return render(request, 'form_sucursal.html', {'form': form})