Как создать DEFAULT_AUTO_FIELD с uuid4 в django?

settings.py
DEFAULT_AUTO_FIELD = 'core.custom_auto_field.UID4AutoField'

from django.db.models.fields import AutoFieldMixin, UUIDField

from uuid import uuid4

class UID4AutoField(AutoFieldMixin, UUIDField):
def get_internal_type(self):
return 'UID4AutoField'

def rel_db_type(self, connection):<br/>
    return UUIDField().db_type(connection=connection)<br/>
Вернуться на верх