This condition always evaluates to True even if it's the same day because it is comparing time.
from datetime import datetime
# ...
if date_num_posts < datetime.today():
How can I check if a date is the same day as datetime.today()?
This condition always evaluates to True even if it's the same day because it is comparing time.
from datetime import datetime
# ...
if date_num_posts < datetime.today():
How can I check if a date is the same day as datetime.today()?
Another alternative is to convert the date in strings and compare them.
from datetime import datetime
today= datetime.today()
if today.strftime('%Y-%m-%d') == other_datetime.strftime('%Y-%m-%d'):
print("same day as today: {0}".format(today.strftime('%Y-%m-%d')))