I am trying to extend the user model in django redux registration. I have tried some possible solutions, but all in vain.
Django Debug shows that is "NotImplementedError at /accounts/register/ No exception message supplied"
I have tried this to solve this problem Moreover, i was following rvlsico answer here on how to get started on it.
Any help would be appreciated. Here are my code snippets: regbackend.py
class MyRegistrationView(RegistrationView):
form_class = ProfileForm
def register(self,form_class):
new_user = super(MyRegistrationView, self).register(form_class)
p = form_class.cleaned_data['teacher']
new_profile = Profile.objects.create(user=new_user, teacher=p)
new_profile.save()
return new_user
models.py
class Profile(models.Model):
user = models.OneToOneField(User, primary_key=True,on_delete=models.PROTECT)
teacher = models.BooleanField(default=False)
@property
def is_teacher(self):
return self.teacher
forms.py
class ProfileForm(RegistrationFormUniqueEmail):
teacher = forms.BooleanField(required=False,label=("Are you a teacher?"))
urls.py
urlpatterns = [
re_path(r'^register/$', MyRegistrationView.as_view(), name='registration_register'),
path('', include('registration.backends.default.urls')),]