tags:

views:

35

answers:

1

Registration usually takes 3 arguments.

-Username

-Password

-Email

But when i try to add a 4th value, it returns this error:

create_user() got an unexpected keyword argument 'hobby'

Any idea how to solve this?

Here's the form i'm using:

    def save(self):
        new_user = User.objects.create_user(
          username=self.cleaned_data['username'],
          password=self.cleaned_data['password1'],
          email=self.cleaned_data['email'],
          hobby=self.cleaned_data['hobby'])
        return new_user

And here's the view i'm using

def register_page(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect("/")
    else:
        form = RegistrationForm()
    return render_to_response("registration/register.html", {'form': form})

To Answer my own question and perhaps to help others with a similar problem, here's what i did:

    def save(self):
        new_user = User.objects.create_user(
          username=self.cleaned_data['username'],
          password=self.cleaned_data['password1'],
          email=self.cleaned_data['email'])
        new_user.hobby=self.cleaned_data['hobby']
        new_user.save()
        return new_user
+2  A: 

You cannot change User model, but you can attach a profile to it that will hold all that additional information. Read this for more.

Sebastjan Trepča
Solved the problem already, but thanks anyway.And on another note, you can change the User model, although it's probably not adviced to do so.