add ai models
This commit is contained in:
@@ -9,7 +9,20 @@ class CommonStatus(models.IntegerChoices):
|
||||
DISABLED = 0, '禁用'
|
||||
ENABLED = 1, '启用'
|
||||
|
||||
class CoreModel(models.Model):
|
||||
|
||||
class AutoCommentModel(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
# 给字段自动添加db_comment
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
super().__init_subclass__(**kwargs)
|
||||
for field in cls._meta.fields:
|
||||
if getattr(field, 'verbose_name', None) and not getattr(field, 'db_comment', None):
|
||||
field.db_comment = field.verbose_name
|
||||
|
||||
|
||||
class CoreModel(AutoCommentModel):
|
||||
remark = models.CharField(max_length=256, db_comment="备注", null=True, blank=True, help_text="备注",
|
||||
verbose_name="备注")
|
||||
creator = models.CharField(max_length=64, null=True, blank=True, help_text="创建人", db_comment="创建人",
|
||||
|
||||
Reference in New Issue
Block a user