Answer the question
In order to leave comments, you need to log in
Django 2. How can I make the registration form inherit from 2 models, for example the built-in user model and my UserProfile model?
There are 2 form classes:
class ExtendedUserCreationForm(UserCreationForm):
email = forms.EmailField(required = True)
class Meta:
model = User
fields = ['username','email','password1','password2']
def save(self,commit = True):
user = super().save(commit = True)
user.email = self.cleaned_data['email']
if commit:
user.save()
return user
class UserProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ('first_name','last_name','father_name')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question