0

am trying to follow the answers provided in Django-Registration & Django-Profile, using your own custom form and Creating a Django Registration Form by Extending Django-Registation Application to extend the django-registration form. I added the following code in url.py

url(r'^accounts/register/$', register, {'backend': 'registration.backends.default.DefaultBackend','form_class': UserRegistrationForm}, name='registration_register'),
(r'^accounts/', include(regUrls)),

but now whenever i access http://localhost:8000/accounts/register/ am getting the following error

register() got an unexpected keyword argument 'form_class'

Please help me out. Why am i getting this error? I goggled a lot but still i could not figure out a solution.

Community
  • 1
  • 1
swaroop
  • 125
  • 2
  • 8

1 Answers1

1

That dictionary in your urls.py entry gets passed as keyword arguments to the view function, register, when you access the page. register doesn't have a keyword argument form_class.

If the register your first link is referring to is the register from the second, the first link is wrong. Because that register doesn't accept that keyword arg. One answer seems to define a different register method, but I think that might be something else(?)

If you understand what the form_class is supposed to be passed to, you could just add the kwarg to register manually too.

Community
  • 1
  • 1
Dave
  • 11,499
  • 5
  • 34
  • 46
  • Thanks Dave, as i said i was just following the posts i have provided above and in there they had given the URL like this. Am very new to django so kind of confused on what needs to be done. So could you tell me how i can fix this issue? Thanks – swaroop Sep 29 '11 at 07:09
  • @swaroop sorry if I wasn't clear. The actual *problem* is that django is calling `register(request, backend = registration.backends.default.DefaultBackend, form_class= UserRegistrationForm)`, but the function `register` is defined as `def register(request):`. It doesn't know how to take those keyword arguments. Unfortunately *I* don't understand what's going on in these posts either, so I can't tell you exactly what was supposed to happen there. But maybe this is somewhere to start. – Dave Sep 29 '11 at 07:14
  • Dave your previous comment itself helped me to solve the issue. It was just that I was not importing the register method from registration.views and after doing that it got solved. Thanks a lot for helping me – swaroop Sep 29 '11 at 07:20