I have this issue with date time, I don't understand the datetime module and django dates either, what I am trying to achieve is get the difference days between a constant datetime saved in the database and current date. See, the problem is even though today is not over I am getting negative -1 day and the day is not over yet.
from django.utils.timezone import now
class ExamplModel(models.Model):
due_date = models.DateTimeField()
# model method
def get_due_date(self):
days_left = due_date - now()
return days_left
if due_date is today a couple of hours ago, example I get result like this -1 day, 18:54:04.590519
instead of 0 day, 18:54:04.590519
How can I solve this.