错误Django / Python的NoReverseMatch

时间:2017-02-16 17:35:33

标签: django

我试图在这里探讨其他问题但是在诊断我的错误时遇到了问题 - 希望有人可以帮助我。

以下是完整错误:

NoReverseMatch at /
Reverse for 'projects' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Error during template rendering

In template /home/django/chrisblog/posts/templates/posts/home.html, error at line 0

当我尝试在网站上创建一些额外的页面时发生错误 - 实际上只是复制另一个页面的模板。这些页面使用带有“base.html”模板的extends标记。

我的网址文件如下所示

from django.conf.urls import url
from django.contrib import admin
import posts.views
import sitepages.views
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', posts.views.home, name="home"),
    url(r'^resources/', sitepages.views.resources, name="resources"),
    url(r'^projects/', sitepages.views.projects, name="projects"),
    url(r'^about/', sitepages.views.about, name="about"),
    url(r'^posts/(?P<post_id>[0-9]+)/$', posts.views.post_details, name="post_detail"),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

和我的观点文件

from django.shortcuts import render
from . import models

def about(request):
    return render(request,'sitepages/about.html')

def resources(request):
    return render(request,'sitepages/resources.html')

def projects(request):
    return render(request,'sitepages/projects.html')

如果这足以继续,请告诉我。谢谢您的帮助。

0 个答案:

没有答案