gpt4 book ai didi

python - NoReverseMatch 在/论坛/

转载 作者:太空宇宙 更新时间:2023-11-04 05:20:40 27 4
gpt4 key购买 nike

我正在尝试实现 django-registration-redux 并使用了由 Andres 编写的模板,网址为 https://github.com/macdhuibh/django-registration-templates .但问题是无论我运行什么,我都会收到 NoReverseMatch 错误。

我尝试渲染 base.html 模板来检查错误,但在第 12 行出现错误。

base.html 是

{% load i18n %}
<html lang="en">

<head>
<link rel="stylesheet" href="{{ STATIC_URL }}style.css" />
<title>{% block title %}User test{% endblock %}</title>
</head>

<body>
<div id="header">
{% block header %}
<a href="{% url 'index' %}">{% trans "Home" %}</a> |

{% if user.is_authenticated %}
{% trans "Logged in" %}: {{ user.username }}
(<a href="{% url 'auth_logout' %}">{% trans "Log out" %}</a> |
<a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a>)
{% else %}
<a href="{% url 'auth_login' %}">{% trans "Log in" %}</a>
{% endif %}
<hr />
{% endblock %}
</div>

<div id="content">
{% block content %}{% endblock %}
</div>

<div id="footer">
{% block footer %}
<hr />
{% endblock %}
</div>
</body>

</html>

index.html 是

{% extends "base.html" %}
{% load i18n %}

{% block content %}
Index page
{% endblock %}

和 urls.py 作为

from django.conf.urls import url
from . import views

app_name = 'forum'
urlpatterns = [

url(r'^$', views.index, name='index'),

]

我得到如下图所示的错误:

Error

最佳答案

您可能需要在标签中指定应用名称:

<a href="{% url 'forum:index' %}">{% trans "Home" %}</a>

关于python - NoReverseMatch 在/论坛/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40469397/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com