Compare date of datetime object in filter django

I use django 3.1.0

I have a release_time field(a DateTimeFeild) in my model, and i want to retrieve those records that have been released in current date.

here is my model:

class Test(models.Model):
  title = models.CharField(max_length=100)
  release_time = models.DateTimeField()
  end_time = models.DateTimeField()

I use the following line to get my data:

cur_time = localtime() // django.utils.timezone.localtime

This always returns an empty query set. I am sure that there are records that have this condition.

PLease tell me am I doing this wrong??

Read more here:

Content Attribution

This content was originally published by fuse13 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: