Generate unique hashes for django models

后端 未结 4 1389
感情败类
感情败类 2021-02-01 07:20

I want to use unique hashes for each model rather than ids.

I implemented the following function to use it across the board easily.

import random,hashlib         


        
4条回答
  •  伪装坚强ぢ
    2021-02-01 08:02

    Use your database engine's UUID support instead of making up your own hash. Almost everything beyond SQLite supports them, so there's little reason to not use them.

提交回复
热议问题