第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Django - 未檢測到模板

Django - 未檢測到模板

qq_笑_17 2021-12-08 16:25:53
我正在使用這個庫來處理 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 pathfrom . import viewsfrom django.conf.urls import url, includefrom django.conf.urls import urlfrom allauth_2fa import views as allauth_2fa_viewsapp_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"),]
查看完整描述

1 回答

?
慕碼人8056858

TA貢獻1803條經驗 獲得超6個贊

該TwoFactorSetup視圖正在使用文件夾allauth_2fa 中的模板setup.html。所以你需要做的就是將你的setup.html放在一個同名的文件夾中:app_folder/templates/allauth_2fa/setup.html來覆蓋它。


或者,子類化TwoFactorSetup并更改template_name屬性以指向您的模板并在您的urls.py 中使用該視圖:


from allauth_2fa.views import TwoFactorSetup


class MySetup(TwoFactorSetup):

    template_name = 'my_app/setup.html'


查看完整回答
反對 回復 2021-12-08
  • 1 回答
  • 0 關注
  • 182 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號