📅  最后修改于: 2022-03-11 14:45:42.572000             🧑  作者: Mango
import datetime
from uuid import uuid4
def create_id():
now = datetime.datetime.now()
return str(now.year)+str(now.month)+str(now.day)+str(uuid4())[:7]
# in your model:
id = models.CharField(primary_key=True, default=create_id, editable=False)