相关疑难解决方法(0)

使用ACCOUNT_FORMS覆盖Django allauth登录表单

我已经使用简单的设置变量覆盖了注册表单,ACCOUNT_SIGNUP_FORM_CLASS但是要覆盖您需要使用的登录表单ACCOUNT_FORMS = {'login': 'yourapp.forms.LoginForm'}.我有我想要的形式,它与crispy-forms和Bootstrap3完美地显示:

class LoginForm(forms.Form):
    login = forms.EmailField(required = True)
    password = forms.CharField(widget = forms.PasswordInput, required = True)

    helper = FormHelper()
    helper.form_show_labels = False
    helper.layout = Layout(
        Field('login', placeholder = 'Email address'),
        Field('password', placeholder = 'Password'),
        FormActions(
            Submit('submit', 'Log me in to Cornell Forum', css_class = 'btn-primary')
        ),
    )
Run Code Online (Sandbox Code Playgroud)

当我提交表格时,我得到了AttributeError at /account/login/ - 'LoginForm' object has no attribute 'login'.这里出了什么问题?原始allauth登录表单的来源是:https://github.com/pennersr/django-allauth/blob/master/allauth/account/forms.py

python forms django django-forms django-allauth

5
推荐指数
1
解决办法
5077
查看次数

标签 统计

django ×1

django-allauth ×1

django-forms ×1

forms ×1

python ×1