Skip to content

Commit

Permalink
1.把基类ORM模型的PK改成了UUID格式 && 同时增加了字段remark来可存储小备注/标签.
Browse files Browse the repository at this point in the history
Signed-off-by: Sadam·Sadik <[email protected]>
  • Loading branch information
Haoke98 committed Dec 27, 2023
1 parent f5bb29f commit d1a6c24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions simplepro/lib/pkHelper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# _*_ codign:utf8 _*_
"""====================================
@Author:Sadam·Sadik
@Email:[email protected]
@Date:2023/11/29
@Software: PyCharm
@disc:
======================================="""
import uuid


def uuid_generator():
return str(uuid.uuid4())
4 changes: 3 additions & 1 deletion simplepro/models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from django.db import models
from simplepro.editor import fields
from simplepro.lib import pkHelper


class BaseModel(models.Model):
# id = models.IntegerField(primary_key=True, null=False, auto_created=True, editable=False)
id = models.CharField(max_length=48, primary_key=True, editable=False, default=pkHelper.uuid_generator)
createdAt = models.DateTimeField(auto_created=True, auto_now_add=True, verbose_name="创建时间", null=True,
editable=False, db_index=True)
updatedAt = models.DateTimeField(auto_now=True, verbose_name="最近更新时间", null=True, editable=False, db_index=True)
deletedAt = models.DateTimeField(verbose_name="被删除时间", null=True, editable=False, db_index=True)
remark = models.CharField(verbose_name="小备注/标签", max_length=100, null=True, blank=True, db_index=True)
info = fields.UETextField(verbose_name='说明', null=True, blank=True)

class Meta:
Expand Down

0 comments on commit d1a6c24

Please sign in to comment.