Change The Type Of User ID To UUID
I'm using User model from django.contrib.auth.models, the default id(primary_key) type is int, how to change it to UUID?, for example id = models.UUIDField(primary_key=True, defaul
Solution 1:
Use AbstractUser model if you need changes in the default user model.
import uuid
from django.db import models
from django.contrib.auth.models import AbstractUser
class MyUser(AbstractUser):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
Then in your settings.py
,
AUTH_USER_MODEL = 'myapp.MyUser'
Post a Comment for "Change The Type Of User ID To UUID"