我正在使用这个库来处理 django 项目的两个因素身份验证,但我遇到了一些麻烦:在我的站点中,我添加了一个setup.html页面,我在我的urls.py文件中设置了 url,但我不断收到这个错误:
In template C:\Users\Us\lib\site-packages\allauth\templates\base.html, error at line 26
Reverse for 'account_email' not found. 'account_email' is not a valid view function or pattern name.
<li><a href="{% url 'account_email' %}">Change E-mail</a></li>
这完全很奇怪,因为我不是在尝试加载名为base.html 的文件,而是我自己的setup.html文件,该文件位于我的项目文件夹中(路径是project-folder>templates>setup.html)。这是我想从我自己的模板加载的setup.html:
{% extends 'main/header.html' %}
{% load i18n %}
{% block content %}
<h1>
{% trans "Setup Two-Factor Authentication" %}
</h1>
<h4>
{% trans 'Step 1' %}:
</h4>
<p>
{% trans 'Scan the QR code below with a token generator of your choice (for instance Google Authenticator).' %}
</p>
<img src="{{ qr_code_url }}" />
<h4>
{% trans 'Step 2' %}:
</h4>
<p>
{% trans 'Input a token generated by the app:' %}
</p>
<form method="post">
{% csrf_token %}
{{ form.non_field_errors }}
{{ form.token.label }}: {{ form.token }}
<button type="submit">
{% trans 'Verify' %}
</button>
</form>
{% endblock %}
看起来我正在使用的模块,而不是加载 MY setup.html会加载其他东西,但我找不到解决这个问题的方法。
这是我调用来处理设置的视图(它是模块的视图):https : //github.com/percipient/django-allauth-2fa/blob/master/allauth_2fa/views.py
这是我自己的urls.py,我提到的视图正在被调用:
from django.urls import path
from . import views
from django.conf.urls import url, include
from django.conf.urls import url
from allauth_2fa import views as allauth_2fa_views
app_name = "main"
urlpatterns = [
path("setup/", allauth_2fa_views.TwoFactorSetup.as_view(), name="setup"),
path("", views.homepage, name="homepage"),
path("register/", views.register, name="register"),
path("logout/", views.logout_request, name="logout"),
path("login/", views.login_request, name="login"),
]
慕码人8056858
相关分类