[Django]-How can i compare two datetimes in Django

3👍

AFAIK datetime.now() is not timezone aware.

Django comes with a helper for this, which requires pytz

 naive = datetime.replace(tzinfo=None)

or you can use timezone instead of datetime to fix this issue.

from django.utils import timezone
now = timezone.now()

You should be able to compare your dates now.

Leave a comment