Question

I use the django-registration module, but this is a django/python question.

In a custom view:

def register(self, request, **cleaned_data):

    firstname, lastname, email, password = cleaned_data['firstname'], cleaned_data['lastname'], cleaned_data['email'], cleaned_data['password']
    if Site._meta.installed:
        site = Site.objects.get_current()
    else:
        site = RequestSite(request)
    new_user = RegistrationProfile.objects.create_inactive_user(email, email,
                                                                password, firstname,
                                                                lastname, site)

    signals.user_registered.send(sender=self.__class__,
                                 user=new_user,
                                 request=request)
    return new_user

And when I send my form, I get this error:

TypeError at /accounts/register/
 create_inactive_user() takes at most 6 arguments (7 given)

pointing at my create_inactive_user(email, email, password, firstname, lastname, site) ... that have 6 arguments!!!

I tried with hard-coded values, but I get the same message.

Was it helpful?

Solution

Judging by the code, that create method isn't expecting a first name and last name argument - self will get passed implicitly, but it wants you to pass it 5 variables - username, email, password, site, and an optional send_email.

You're giving it too many (and incorrect) arguments :)

OTHER TIPS

When you call a method, self is implicitly added as the first argument.

Did you forget to include self as the first argument in the function definition?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top