Django by default makes a primary key field on each model named "id
", with a type of AutoField
. On my models, I'm overriding this to use a custom UUIDField
as the primary key by using the "primary_key
" attribute. I would also like the User
model in django.contrib.auth
to have a UUIDField
as the primary key, but this doesn't seem to be possible without changing the User
model source code.
Is there any recommended way to approach this problem?
One could leverage just the AbstractUser
and make the following changes
class CustomUser(AbstractUser):
email = models.EmailField(max_length=254, unique=True, db_index=True, primary_key=True)
name = models.CharField(max_length=50)
USERNAME_FIELD = 'email'
REQUIRED_FILEDS = ['name']
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