Question : add year to id django
Answered by : difficult-dogfish-b5zjaz6ummuk
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)
Source : https://stackoverflow.com/questions/45784965/django-create-a-custom-id | Last Update : Mon, 13 Jul 20
Question : add year to id django
Answered by : smiling-stork-cxusj5ozaqle
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]
Source : https://w3programmers.org/questions/45784965/Django--Create-a-custom-id | Last Update : Thu, 07 Apr 22