I am trying to filter by time to delete messages from an sqlite3 database. I am taking a string that is accurate to the minute, converting that to a datetime object, and using the filter function on the QuerySet of messages. However, the entry in the database is far more precise than the string, so the message I'm looking for is being filtered out as well.
I'm automatically generating the datetime object using
class Message(models.Model):
....
time = models.DateTimeField(auto_now_add=True)
I'm filtering using
Message.objects.all().filter(time=time)
For example, the string I'm using to create the datetime object to filter is 'Dec. 5, 2015, 5:07 PM' to create a datetime object '2015-12-05 05:07:00'. However, the message I'm looking for is from time '2015-12-05 17:07:19.308321'
Is there an option to make the auto-generated datetime objects less precise, to the minute instead of fraction of a second?