Exemplo n.º 1
0
def expedientes_edit(request, expedienteitem_pk):
    data = None
    if request.method == 'POST':
        data = request.POST
    #expediente_item = Expedientes.objects.get(pk=expedienteitem_pk)
    expedientes_item = get_object_or_404(Expedientes, pk=expedienteitem_pk)
    expedientes_form = ExpedientesForm(data=data,
                         instance=expediente_item)
    if expedientes_form.is_valid():
        expedientes_form.save()
        return HttpResponseRedirect(reverse('expedientes_list'))
    return render_to_response('expedientes/expedientes_edit.html',
                              {'expedientes_form': expedientes_form},
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def expedientes_add(request):
    data = None
    if request.method == 'POST':
        data = request.POST
    initial = {'fecha_solicitud': datetime.now()}
        # establece valor inicial a este campo
    expedientes_form = ExpedientesForm(data=data,
                         initial=initial)
    if expedientes_form.is_valid():
        #basicos en funcion al tipo de datos
        expedientes_form.save()
        return HttpResponseRedirect(reverse('expedientes_list'))
    return render_to_response('expedientes/expedientes_add.html',
                              {'expedientes_form': expedientes_form},
                              context_instance=RequestContext(request))