我试图在MongoDB数据库中记录一些时间和日期。但是我无法让它们正确显示。在数据库中,它显示为ISODate("2018-11-05T20:57:53.233Z")
,但是当我尝试显示日期时,它显示为{'$date': 1541451473242}
。如果我使用value|date:"m d Y"
,它将完全不显示。我将在下面发布我的模型代码。
Model.py
class Promotion_Code_Info(EmbeddedDocument):
promo_code = StringField(max_length=200, required=True)
code_active = BooleanField(default = True)
use_number = IntField(required=True)
sent_when = DateTimeField(required=False)
customer_email = EmailField(required=False)
code_added = DateTimeField(default=datetime.datetime.utcnow)
code_exp = DateTimeField(default=datetime.datetime.utcnow)
class Promotion_Lists(Document):
user_id = IntField(required=True)
unique_promo_id = StringField(max_length=16, required=True)
promo_name = StringField(max_length=200, required=True)
code_list = ListField(EmbeddedDocumentField(Promotion_Code_Info))
amount_active = IntField(required=True)
amount_used = IntField(required=True)
total = IntField(required=True)