0

(Django 1.8, Django-Registration-Redux 1.4)

After following the answer in this SO post: django-registration-redux add extra field

I've implemented a custom view with my own template to register a user, and my custom form is correctly rendered.

user_views.py

class SignupView(RegistrationView):

    form_class = MyRegistrationForm

    def register(self, request, form):

        print form
        print request

        new_user = super(SignupView, self).register(request, form)

        my_user_model = MyUserModel()
        my_user_model.user = new_user
        my_user_model.save()

        return new_user

However, register doesn't seem to get called. But, when I define post() - the request comes through with all of the form data.

urls.py

url(
    r'^accounts/register/',
    user_views.SignupView.as_view(),
    name='signup'
),  # Customized-Register

url(
    r'^accounts/',
    include('registration.backends.default.urls')
),  # Registration-Redux

Would appreciate guidance on the correct usage, thanks!

Community
  • 1
  • 1
r89n
  • 41
  • 5

2 Answers2

0

Ok - I've determined the solution. It had to do with my custom form not collecting the (required) username field.

Incase it helps, I figured it out by implementing form_invalid(self, form) as RegistrationView is a derived class of Django's FormView, which hinted me towards it.

This SO answer helped override the username requirement: Django Registration Redux: how to change the unique identifier from username to email and use email as login

Hope it helps

Community
  • 1
  • 1
r89n
  • 41
  • 5
0

Try this line:

new_user = super(MyRegistrationView, self).register(form_class)

and change the url to:

url(r'^accounts/register/$', MyRegistrationView.as_view(),
        name='registration_register'),

Hope it works!

tread
  • 10,133
  • 17
  • 95
  • 170
rahul.m
  • 5,572
  • 3
  • 23
  • 50