I'm writing a manager in Django 1.5. I want to return a QuerySet
that contains objects with a start date either today or in the future. Based on this answer to a previous problem I presume my manager needs to use a callable rather than a function. I've written:
...
return super(UpcomingEventManager, self).get_query_set().filter(date__gte=timezone.now().date)
I read that code as being a callable (date
) that relies on a function (timezone.now()
) for its value. But will Django treat it as a callable or a function?
I know I can test this by creating an object and waiting until tomorrow but I'd rather understand this fully.
Django 1.10 get today date:
>>> from django.utils import timezone
>>> timezone.now()
datetime.datetime(2016, 11, 29, 7, 23, 55, 924928, tzinfo=<UTC>)
>>> timezone.now().date
<built-in method date of datetime.datetime object at 0x7f42512b42a0>
>>> timezone.now().date()
datetime.date(2016, 11, 29)