Peewee Python 默认值未反映在 DateTimeField 中

Peewee Python Default is not reflecting in DateTimeField

尽管使用了 DateTimeField(默认=datetime.datetime.now),但仍无法设置默认时间戳 该列设置为非空但未设置默认值

我有我的模型

import datetime

database = PostgresqlDatabase(dbname,username,password,host)

class BaseModel(Model):
    class Meta:
        database = database

class UserInfo(BaseModel):
     id = PrimaryKeyField()
     username = CharField(unique=True)
     password = CharField()
     email = CharField(null=True)
     created_date = DateTimeField(default=datetime.datetime.now)

当我使用此模型和以下代码创建 table 时

 database.connect()
 database.create_tables([UserInfo])

我低于 table

                                  Table "public.userinfo"
Column        |            Type             |                       Modifiers                       
--------------+-----------------------------+-------------------------    ------------------------------
 id           | integer                     | not null default    nextval('userinfo_id_seq'::regclass)
 username     | character varying(255)      | not null
 password     | character varying(255)      | not null
 email        | character varying(255)      | 
 created_date | timestamp without time zone | not null
Indexes:
    "userinfo_pkey" PRIMARY KEY, btree (id)
    "userinfo_username" UNIQUE, btree (username)

此处 table 创建日期未设置为任何默认值

When using the default parameter, the values are set by Peewee rather than being a part of the actual table and column definition

尝试created_date = DateTimeField(constraints=[SQL('DEFAULT CURRENT_TIMESTAMP')])