Hi everyone,
I am using django-userena and extend the form class to add some of my own fields. I followed
the demo and still get the above error. Anyone know what I am doing wrong?
class SignupFormExtra(SignupForm):
"""
A form to demonstrate how to add extra fields to the signup form, in this
case adding the first and last name.
"""
first_name = forms.CharField(label=_(u'First name'),
max_length=30,
required=True)
last_name = forms.CharField(label=_(u'Last name'),
max_length=30,
required=False)
industry = forms.CharField(label=_(u'Industry'),
max_length=50,
required=False)
title = forms.CharField(label=_(u'title'),
max_length=50,
required=False)
def __init__(self, *args, **kw):
"""
A bit of hackery to get the first name and last name at the top of the
form instead at the end.
"""
super(SignupFormExtra, self).__init__(*args, **kw)
# Put the first and last name at the top
new_order = self.fields.keyOrder[-2]
new_order.insert(0, 'first_name')
new_order.insert(1, 'last_name')
new_order.insert(2, 'industry')
new_order.insert(3, 'title')
self.fields.keyOrder = new_order
def save(self):
"""
Override the save method to save the first and last name to the user
field.
"""
# First save the parent form and get the user.
new_user = super(SignupFormExtra, self).save()
new_user.first_name = self.cleaned_data['first_name']
new_user.last_name = self.cleaned_data['last_name']
new_user.industry = self.cleaned_data['industry']
new_user.title = self.cleaned_data['title']
new_user.save()
# Userena expects to get the new user from this form, so return the new
# user.
return new_user