I've written my first application Django 2.0
.
Everything is working fine and the application is almost ready when I realized to replace id
primary key field from default integer
type to UUID
to make database entry more secure.
When I searched for this how to change id
of user table to UUID
I got many tutorials extending AbstractBaseUser
.
Here is I have written own User
model.
account/models.py
class User(AbstractBaseUser):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
But I'm confused more with examples on different sources.
Every example is adding few more fields in extended model like
first_name
last_name
is_staff
is_admin
active
and functions as
def get_fullname(self):
def get_shortname(self):
etc.
I think all these fields and functions are there by default in AUTH_USER_MODEL
.
Does extending AbstractBaseUser
overwrites AUTH_USER_MODEL
and it is required to add all fields which is there by default?
also, I'm using settings.AUTH_USER_MODEL
as foreign key in different models. Should It be replaced by account.User
model?
I'm also using django-allauth
plugin to enable login using the social network and use email only for authentication. Do I require to add email
field in the extended model with unique=True
?