You seem to be using callback in a way I don't recognise here.
timezone.now()
returns a value of type datetime.datetime
. That class has a property, date
, which returns the date portion of that value. There are no callbacks involved here at all.
Edit Your confusion is stemming from a mis-reading of the previous question. That's about default values used in model field declarations: as the answers there state, you need to use a callable rather than a value because the declaration is evaluated on first import.
But that's not what you're doing here at all. You're simply passing a value to a function from another function. There's no early evaluation involved: the code will be evaluated when the function is called, so it's perfectly safe to use date()
or today()
there. In fact, in this case passing the callable rather than the value will not work.
(Also, you should use the word "callable" rather than "callback" here: a callback implies some sort of asynchronous behaviour, which isn't what's happening.)