I'm trying to filter my request based on a date field.
I would like to check if a date is greater than the current date.
This is what I tried, based on this answer : How do I filter query objects by date range in Django?
orders.object.filter(deliveryDay__gt = date.today()).order_by('-id')
Once I get the orders that are not yet delivered, I want to return them to my API to be able to process them in the front-end
Unfortunately it didn't work in my query which returns all orders to me regardless of the date.
I don't understand where is my error.
This is my model :
class order(models.Model):
user = models.ForeignKey(memberArea, on_delete=models.CASCADE)
comment = models.TextField(null=True, blank=True)
orderDay = models.DateTimeField(auto_now_add=True)
deliveryDay = models.DateField()
deliveryAddress = models.CharField(max_length=255)
state = models.CharField(max_length=255, null=True,
blank=True, default="Waiting")
price = models.TextField(null=True, blank=True)
response = models.TextField(null=True, blank=True)
shop = models.ForeignKey(Shop, on_delete=models.CASCADE, null=True, blank=True)
Thank you by advance for your help.