You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I,m define datetime field in parent model, and set datetime defualt in parent model like:
`
class MetaModel(Model):
id = AutoField(primary_key=True)
create_time = DateTimeField(default=lambda: dt.datetime.now())
update_time = DateTimeField(default=lambda: dt.datetime.now())
class Meta:
database = db
`
and use parent model in child model like:
`
class User(MetaModel):
name = CharField()
gender = BooleanField(default=True)
mobile = CharField(null=True)
class Meta:
table_name = "users"
`
but when generate migration file, not get default like:
`
@migrator.create_model
class User(pw.Model):
id = pw.AutoField()
create_time = pw.DateTimeField()
update_time = pw.DateTimeField()
is_delete = pw.BooleanField(constraints=[SQL("DEFAULT False")], default=False)
name = pw.CharField(max_length=255)
gender = pw.BooleanField(constraints=[SQL("DEFAULT True")], default=True)
mobile = pw.CharField(max_length=255, null=True)
class Meta:
table_name = "users"`
I,m use peewee=3.14.4 peewee-migrate=1.4.6
The text was updated successfully, but these errors were encountered:
Hi,
I,m define datetime field in parent model, and set datetime defualt in parent model like:
`
class MetaModel(Model):
id = AutoField(primary_key=True)
create_time = DateTimeField(default=lambda: dt.datetime.now())
update_time = DateTimeField(default=lambda: dt.datetime.now())
`
and use parent model in child model like:
`
class User(MetaModel):
name = CharField()
gender = BooleanField(default=True)
mobile = CharField(null=True)
`
but when generate migration file, not get default like:
`
@migrator.create_model
class User(pw.Model):
id = pw.AutoField()
create_time = pw.DateTimeField()
update_time = pw.DateTimeField()
is_delete = pw.BooleanField(constraints=[SQL("DEFAULT False")], default=False)
name = pw.CharField(max_length=255)
gender = pw.BooleanField(constraints=[SQL("DEFAULT True")], default=True)
mobile = pw.CharField(max_length=255, null=True)
I,m use peewee=3.14.4 peewee-migrate=1.4.6
The text was updated successfully, but these errors were encountered: