Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

add year to id django

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)
Comment

add year to id django


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]

Comment

PREVIOUS NEXT
Code Example
Python :: python print exception type and message 
Python :: python tkinter change label text 
Python :: open an exe file using python 
Python :: radix sort python 
Python :: get all files of a drive folder to google colab 
Python :: How to create an infinite sequence of ids in python? 
Python :: erreur install pyaudio 
Python :: SQL Query to Join Two Tables Based Off Closest Timestamp 
Python :: pandas drop extension name from list of files 
Python :: get datafram colum names as list python 
Python :: list python shuffling 
Python :: matplotlib display axis in scientific notation 
Python :: YouCompleteMe unavailable: requires Vim compiled with Python (3.6.0+) support. 
Python :: create a response object in python 
Python :: how to activate virtual environment in python 
Python :: how to use python to open camera app using python 
Python :: how to get index of week in list in python 
Python :: how to convert a dense matrix into sparse matrix in python 
Python :: python beep 
Python :: pandas read excel 
Python :: discord bot python on reaction 
Python :: how to make a tick update in python 
Python :: pandas series to list 
Python :: plt.savefig without showing 
Python :: how to extract zip file in jupyter notebook 
Python :: Get value from TextCtrl wxpython 
Python :: pythonic 
Python :: pickle load 
Python :: python distance of coordinates 
Python :: python strftime iso 8601 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =