Categories
Python Answers

How to filter a date of a DateTimeField in Python Django?

Spread the love

To filter a date of a DateTimeField in Python Django, we can use filter with a datetime.

For instance, we write

YourModel.objects.filter(datetime_published=datetime(2018, 03, 27))

to call filter to return the results with the datetime_published field set to 2018-03-27.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *