use MyUser to auth in django

Asking for your help, because can’t find right answer by myself. I made custom registration form in django with additional fields. To save that fields in database i made custom user in my models. And it works ok(as i understand). But it seems that auth is using the old User model. I have two thoughts:
1- I need to overwrite some method in MyUser.
2- I found some information about adding AUTH_USER_MODEL variable in my settings ( but it call some errors)

forms.py

class MyRegistrationForm(UserCreationForm):
    bdate=forms.DateField(required=True)
    phone=forms.CharField(required=True)
    captha=CaptchaField(required=True)


    class Meta:
        model=MyUser
        fields=('username','first_name','last_name','email','bdate','phone','password1','password2')

    def save(self, commit=True):
        user = super(MyRegistrationForm, self).save(commit=False)
        user.bdate=self.cleaned_data['bdate']
        user.phone=self.cleaned_data['phone']

        if commit:
            user.save()
        return user

models.py

class MyUser(User):
    bdate=models.DateField()
    phone=models.CharField(max_length=10)


Source: python

Leave a Reply