I would like to manage timestamps in my database using seconds since epoch using a PeeWee IntegerField rather than a DateTimeField. I know that the field definition can take a default value using a callable, but I would need to do something like:
timestamp = IntegerField(default=int(datetime.datetime.now().strftime('%s')))
Which I suppose is incorrect since the default value should not actually invoke the callable.
I also tried wrapping this in a function and passing that function as a callable:
def get_timestamp():
return int(datetime.datetime.now().strftime('%s'))
timestamp = IntegerField(default=get_timestamp)
However this did not work either.
Is there a way to accomplish this, or do I have to retro-fit my data to use DateTimeFields instead?