Set up a collection with mongoengine, where time is defined like this.
from mongoengine import Document, DateTimeField import datetime class Post(Document): created = DateTimeField(default=datetime.datetime.utcnow())
In the process of inserting data, the insertion time is always the same. The following are the data that I manually inserted, but I found that some ten sentences have the same time. The following are the data that I read out. I can see that several pieces have the same time, and the interval between these pieces of data is several minutes:
50f2bf6c674d9a1136de4964 • 2013-01-13 14:06:33.717000 • root • 0 50f2bf9c674d9a1136de4965 • 2013-01-13 14:06:33.717000 • root • 0 50f2bfc6674d9a1136de4966 • 2013-01-13 14:06:33.717000 • root • 0 50f2c01f674d9a1136de4967 • 2013-01-13 14:06:33.717000 • admin • 0 50f2c1b8674d9a1136de4968 • 2013-01-13 14:06:33.717000 • admin • 0 50f2b909674d9a1118d57170 • 2013-01-13 13:37:03.176000 • root • 0 50f2b681674d9a11023af511 • 2013-01-13 13:28:07.676000 • root • 0
There was a similar problem on Django platform. Post date was only generated after the object was created, so the same time would occur.
http://stackoverflow.com/questions/27 …MongoEngine draws lessons from Django.
Resolution:
will
datetime.datetime.utcnow()
insteaddatetime.datetime.utcnow
You can see clearly that there are no brackets here.