I'm using the following code to generate a UUID for every new instance of a model object:
def make_uuid(type):
"""Takes an entity type identifier string as input and returns a hex of UUID2 with a
type identifier pre-pended for readability"""
return str(type)+str(uuid.uuid1().hex)
Model field:
account_uuid = models.CharField(max_length=34, default=make_uuid('AC'), db_index=True, unique=True)
When I actually run the app, the first attempt works great, but the second and all subsequent attempts fail with the following message:
Exception Type: IntegrityError
Exception Value: duplicate key value violates unique constraint "accounts_accounts_account_uuid_key"
Any ideas as to what might be going on?