Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ExpedienteList(ListView):
- model = expediente
- template_name = 'expediente/expedienteList.html'
- ordering = '-fecha'
- def get_queryset(self):
- # por defecto solo trae los expedientes del dia
- hoy = date.today()
- qs = super().get_queryset()
- filtros2 = {}
- # verificamos que vengan por peticion para entrar en el ciclo
- if self.request.method == 'GET':
- # declaramos la variables que vienen del formulario
- fecha1 = self.request.GET.get('fechad')
- fecha2 = self.request.GET.get('fechah')
- dato = self.request.GET.get('dato')
- print(dato)
- # declaro mi diccionario para el filtro
- filtros2 = {}
- if fecha1 or fecha2 or dato:
- if fecha1:
- if fecha2:
- filtros2.update({"fecha__range": (fecha1, fecha2)})
- else:
- filtros2.update({"fecha__date": (fecha1)})
- elif fecha2:
- filtros2.update({"fecha__date": (fecha2)})
- if dato:
- filtros2.update({"cuenta__icontains": (dato)})
- else:
- return qs.filter(fecha__date=date.today())
- logging.info('filtro final a aplicar:')
- logging.debug(filtros2)
- return qs.filter(**filtros2).order_by('-fecha')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement