12345678910111213141516171819 |
- from django.conf import settings
- from photo.models import UUIDInfo
- import shortuuid
- def curtailUUID(model, field='uuid', length=settings.CURTAIL_UUID_LENGTH):
- flag = True
- while flag:
- uuid = shortuuid.uuid()[-length:]
- try:
- model.objects.get(**{field: uuid})
- except model.DoesNotExist:
- flag = False
- return uuid
|