0
我已經安裝Django的登記-Redux的超控,以節省下面的附加模型用戶配置:查看多種形式未保存(缺少形式1個位置參數)
class UserProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
tel_number = models.CharField(max_length=20, null = True)
這是設置與以下形式:
class UserProfileRegistrationForm(RegistrationFormUniqueEmail):
tel_number = forms.CharField()
而且regbackend.py:
from registration.backends.default.views import RegistrationView
from .forms import UserProfileRegistrationForm
from .models import UserProfile
class MyRegistrationView(RegistrationView):
form_class = UserProfileRegistrationForm
def register(self, request, form_class):
new_user = super(MyRegistrationView, self).register(request, form_class)
user_profile = UserProfile()
user_profile.user = new_user
user_profile.tel_number = form_class.cleaned_data['tel_number']
user_profile.save()
return user_profile
然而,即使觀點負載正確,我可以填寫它,每次節省時我收到以下錯誤:
register() missing 1 required positional argument: 'form_class'
我認爲這是傳遞不正確的東西?