【发布时间】:2011-09-29 01:49:09
【问题描述】:
我正在尝试在我的网站中使用 django.contrib.auth.views.login 的每个页面中放置一个登录表单。我在 templatetags/mytags.py 中创建了一个模板标签,我在其中定义了一个名为 get_login 的函数,如下所示:
@register.inclusion_tag('registration/login.html', takes_context=True)
def get_login(context):
...
return {'formLogin': mark_safe(AuthenticationForm())}
...在base.html中:
{% load mytags %}{% get_login %}
现在的问题是模板(registration/login.html)无法识别{{ formLogin.username }},{{ formLogin.password }}...等等。
我错过了什么?
【问题讨论】:
标签: django forms authentication login django-templates