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, default=uuid.uuid4, editable=False)
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With