I need the result from a query that filters two dates from the same model. I need to get in the result 5 days (today plus 4 days) from original date and sale from target date (today plus 4 more days) both in the same query.
This is my code:
startdate = datetime.now().date()
endate = datetime.now().date() + timedelta(days=4)
lineas_de_reporte = Reporteots.objects.filter(original_fcd_date__range=[startdate, endate], target_pdate__range=[startdate, endate])
But I'm not getting the result I want, any idea?
In your code, don't use bracket with __range.
startdate = datetime.date().today()
endate = datetime.date().today() + timedelta(days=4)
lineas_de_reporte = Reporteots.objects.filter(original_fcd_date__range=(startdate, endate), target_pdate__range=(startdate, endate))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.