'Filter between dates in MongoEngine
I have a problem filtering between date_from and date_to in MongoEngine.
This is the document structure
and the next MongoEngine query:
def devices_graph(device_name: str, date_from: str, date_to: str) -> list:
device = (
Device.objects(
device_name=device_name,
graph_data__date__gte=datetime.strptime(date_from, "%d/%m/%Y"),
graph_data__date__lte=datetime.strptime(date_to, "%d/%m/%Y"),
)
.exclude("device_name")
.exclude("last_update")
.exclude("id")
.exclude("rt_temperature")
.exclude("rt_humidity")
)
return device
Im trying to get a list of emmbedded documents between to dates but i always getting a empty list. Someone can help pls
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
