Django allauth 访问视图
我正在尝试使用django-allauth,并希望在我的自定义模板中提供指向allauth视图的链接。以下是相关的模板代码:
{% if request.user.is_authenticated %}
<a href="{% url 'allauth.account.views.logout' %}">Sign Out</a>
{% else %}
<a href="#user-form" class="popup-with-form">Login</a> <a href="#user-form2" class="popup-with-form2">Register</a>
{% endif %}
这段代码是在检查用户是否已经登录,如果登录了,就提供一个注销的链接。我在之前的项目中使用过这段代码,没遇到过问题。在那些项目中,我使用的是django-allauth==0.12.0
。我以为问题可能出在我这次项目中使用了最新版本的allauth(0.16.x
),但是即使我把版本降回0.12.0
,仍然出现同样的错误。谢谢你的帮助。
补充:我遇到的错误是
NoReverseMatch at /app/
Reverse for 'allauth.account.views.logout' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []