I have this code in my model:
added_time = models.DateTimeField(
default=datetime.datetime.now()
)
After migrating and rebooting uwsgi, I get the first datetime in MariaDB now, and further on - exactly the same as after resetting uwsgi.
2015-04-19 16:01:46
2015-04-19 16:01:46
2015-04-19 16:01:46
2015-04-19 16:01:46
I fixed it by changing the code to:
added_time = models.DateTimeField(
auto_now_add=True
)
Although I fixed the problem, I'm not quite sure why this behavior was even like that?
source
share