We need to modify the User's table to be able to store in more fields such as social login tokens, stripe ids etc. We do not want to use the default django.contrib.auth.models.User. We also want to make sure that authentication and authorization will NOT be done via the django.contrib.auth.models.User (default) but this new table that we create (also named as User)
This new table will be inherited like this
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
...
google_login_token = models.CharField(_("Google Login Token"), max_length=255, null=True, blank=True)
# other model fiels go here as usual
You can tell the settings.py files to use this new model that you have created for authentication and authorization by writing the following inside settings.py:
AUTH_USER_MODEL = "users.User"
This new table called Profile will reside inside users/models.py. The fields of this table will include:
Scope
changes to be done inside 'users' app
Description
We need to modify the User's table to be able to store in more fields such as social login tokens, stripe ids etc. We do not want to use the default
django.contrib.auth.models.User
. We also want to make sure that authentication and authorization will NOT be done via thedjango.contrib.auth.models.User
(default) but this new table that we create (also named asUser
)This new table will be inherited like this
You can tell the
settings.py
files to use this new model that you have created for authentication and authorization by writing the following insidesettings.py
:This new table called
Profile
will reside insideusers/models.py
. The fields of this table will include:References
https://www.youtube.com/watch?v=8jyyuBaZwVU