I am new in Django.
I created Sponsor model that model has start_date
(start date become sponsor) and end_date
(end date of sponsor).
start_date = models.DateField(
_("Start date"),
default=datetime.date.today)
end_date = models.DateField(
_("End date"),
default=datetime.date.today)
I want to put all logic inside the model, if that not possible then I want to put the logic in a view. I make method current_sponsor
which can return True or False (if today is on a range of start_date and end_date means True
else False
).
This is my current_sponsor
method
def current_sponsor(self):
today = datetime.date.today
if today >= self.start_date:
return True
elif today <= self.end_date:
return True
else:
return False
The problem is I got error can't compare datetime.datetime to builtin_function_or_method
.
I've tried to see the data using django shell it seem works but the reality does not work.