Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Marta Miranda
/
boletin_api
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Enzo Yair
2023-09-18 08:21:49 -0300
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
ab1b7a646beeb7060f19e23c02d940a7f77bce6c
ab1b7a64
2 parents
effecce8
38f0f2e5
Merge branch 'develop' of
http://gitlab.catamarca.gob.ar/mvmiranda/boletin_api
i…
…nto fix/fecha_modificacion
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
project/apps/edicto/filters.py
project/apps/edicto/filters.py
View file @
ab1b7a6
from
django_filters
import
rest_framework
as
filters
from
django.db.models
import
Q
from
edicto.models
import
Edicto
,
Precio
class
EdictoFilter
(
filters
.
FilterSet
):
fecha_creacion__gte
=
filters
.
DateFilter
(
field_name
=
"fecha_creacion"
,
lookup_expr
=
'gte'
,
label
=
'Desde'
)
fecha_creacion__lte
=
filters
.
DateFilter
(
field_name
=
"fecha_creacion"
,
lookup_expr
=
'lte'
,
label
=
'Hasta'
)
class
Meta
:
model
=
Edicto
fields
=
{
'usuario'
:
[
'exact'
],
'estado'
:
[
'exact'
],
'uuid'
:
[
'exact'
],
}
fecha_creacion__gte
=
filters
.
DateFilter
(
field_name
=
"fecha_creacion"
,
lookup_expr
=
'gte'
,
label
=
'Desde'
)
fecha_creacion__lte
=
filters
.
DateFilter
(
field_name
=
"fecha_creacion"
,
lookup_expr
=
'lte'
,
label
=
'Hasta'
)
estado
=
filters
.
CharFilter
(
field_name
=
'estado'
,
method
=
'obtener_estados'
)
def
obtener_estados
(
self
,
queryset
,
name
,
value
):
cadena
=
value
separador
=
","
lista_estados
=
cadena
.
split
(
separador
)
filtro
=
Q
()
for
t
in
lista_estados
:
filtro
=
filtro
|
Q
(
estado__icontains
=
t
)
return
queryset
.
filter
(
filtro
)
class
PrecioFilter
(
filters
.
FilterSet
):
...
...
Please
register
or
login
to post a comment