【发布时间】:2023-04-03 17:10:02
【问题描述】:
我在 django 中收到“Reverse for ''home'' with arguments '()' and keyword arguments '{}' not found”错误。谁能帮我解决这个问题。
我的 base.html 是
<html>
<head>
<title>Steel Rumors</title>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/main.css" />
</head>
<body>
<h1>Steel Rumors</h1>
{% block content %}
{% endblock %}
<footer>
<p>
<a href="{% url 'home' %}">Home</a>
</p>
</footer>
</body>
</html>
我的 urls.py 是
from django.conf.urls import patterns, include, url
from links.views import LinkListView
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^$', LinkListView.as_view(), name='home'),
url(r"^login/$", "django.contrib.auth.views.login",
{"template_name": "login.html"}, name="login"),
url(r"^logout/$", "django.contrib.auth.views.logout_then_login",
name="logout"),
)
view.py 是
from django.views.generic import ListView
from .models import Link, Vote
class LinkListView(ListView):
model = Link
queryset = Link.with_votes.all()
paginate_by = 3
django 1.4 版 提前致谢
【问题讨论】:
-
你使用的是哪个版本的 django?
-
设置
DEBUG=True它会给你更详细的信息。