'Abstract User in Djang All Auth
I use the Abstract User in my registration using the all auth plugin instead of the contrib auth.
Here is my code in forms.py:
class CustomSignupForm(UserCreationForm):
first_name = forms.CharField(max_length=30, label='First Name', widget=forms.TextInput(attrs={'placeholder': 'First Name','required':'required'}))
last_name = forms.CharField(max_length=30, label='Last Name', widget=forms.TextInput(attrs={'placeholder': 'Last Name','required':'required'}))
email = forms.EmailField(max_length=40, label='Email Address', widget=forms.TextInput(attrs={'placeholder':'Email Address','required':'required'}))
class Meta:
model = Registrations
fields = ['first_name', 'last_name','email', 'user_type']
In my models.py:
class Registrations(AbstractUser):
usertype =[
('Student', 'Student'),
('Staff', 'Staff')
]
user_type = models.CharField(max_length=10,choices=usertype, blank=True, null=True)
And here is the settings.py for my registration:
ACCOUNT_FORMS = {'signup': 'libraryApp.forms.CustomSignupForm',}
AUTH_USER_MODEL = 'libraryApp.Registrations'
My very concern is that if I did it right using the abstract user with the Django All Auth because I have not seen tutorials regarding the use of abstract user in All Auth.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
