1import datetime
2from uuid import uuid4
3def create_id():
4 now = datetime.datetime.now()
5 return str(now.year)+str(now.month)+str(now.day)+str(uuid4())[:7]
6
7# in your model:
8id = models.CharField(primary_key=True, default=create_id, editable=False)