【发布时间】:2013-04-05 23:04:19
【问题描述】:
我正在尝试使用 django-crispy-forms 在 django 中显示带有登录视图的内置 AuthenticationForm。我在继承 AuthenticationForm 时遇到问题 - 我收到 AttributeError。错误显示'WSGIrequest' object has no attribute 'get'. 这是我的表单:
class LoginForm(AuthenticationForm):
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Field('username', placeholder="username"),
Field('password', placeholder="password"),)
super(AuthenticationForm, self).__init__(*args, **kwargs)
我认为此错误与通过 get 从重定向调用的登录视图有关(我使用的是 @login_required 装饰器)。有人对如何使用 django-crispy-forms 子类化内置表单并避免此错误有任何想法吗?
【问题讨论】:
标签: python django django-crispy-forms