[Answer]-Add a reset date in python/django

1👍

Convert the field into a datetime in code using dateutil.parser before comparing it to the current date:

from dateutil import parser
from datetime import datetime

object_date = parser.parse(my_obj.datefield)
if object_date < datetime.now():
    # Do something
else:
    # Do something else

You can install dateutil using pip install python-dateutil

Leave a comment