Автор Userena здесь.У меня уже была переписка по электронной почте с "no_access", но стоит указать решение, если у других есть такая же проблема.Первая ошибка состояла в том, что метод save
возвращает профиль.Это не правда, он возвращает Django User
.Из-за этого вам сначала нужно получить профиль и внести в него изменения.Сохраните профиль и затем верните пользователя снова, чтобы он был совместим с Userena.
Для модели Business
просто добавьте его также в методе save
.
class SignupFormExtra(SignupForm):
address = forms.CharField(label=_(u'Address'),max_length=30,required=False)
contact = forms.CharField(label=_(u'Contact'),max_length=30,required=False)
business = forms.CharField(label=_(u'Business Name'),max_length=30,required=False)
def save(self):
"""
Override the save method to save the first and last name to the user
field.
"""
# Original save method returns the user
user = super(SignupFormExtra, self).save()
# Get the profile, the `save` method above creates a profile for each
# user because it calls the manager method `create_user`.
# See: https://github.com/bread-and-pepper/django-userena/blob/master/userena/managers.py#L65
user_profile = user.get_profile()
# Be sure that you have validated these fields with `clean_` methods.
# Garbage in, garbage out.
user_profile.address = self.cleaned_data['address']
user_profile.contact = self.cleaned_data['contact']
user_profile.save()
# Business
business = self.cleaned_data['business']
business = Business.objects.get_or_create(name=business)
business.save()
# Return the user, not the profile!
return user
Послесоздавая форму, не забудьте переопределить форму userena в вашем urls.py.Что-то вроде этого подойдет:
url(r'^accounts/signup/$',
userena_views.signup,
{'signup_form': SignupFormExtra}),
Это должно сработать!Удачи.