找不到 Django 2.0 页面,url 模式不匹配

Django 2.0 page not found, url patterns did not match

我刚刚将我的 django 项目从 1.8.5 升级到 2.0.6 版本。我能够进入索引页面,但任何其他 link 都会给我一个 404 页面。 enter image description here。有什么问题?非常感谢。

这是我的一部分 urls.py

from django.conf.urls import *
from django.contrib import admin
from django.contrib.admin.views.decorators import staff_member_required
from . import views


urlpatterns = [
  url(r'^admin/', admin.site.urls),
  url(r'^historicalbackground/', views.historicalbackground, name="historicalbackground"),
 url(r'^organizations/$', views.organizations, name="Organizations page"),      
]

这里是 views.py

from django.views.generic.base import TemplateView
from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.template import RequestContext, loader, Context
from django.template.loader import get_template
from django.shortcuts import render, render_to_response, redirect
from django.core import management, serializers
from .models import Person, Place, Org, Relationship, Page, Manuscript, PendingTranscription
from html.parser import HTMLParser
from tempfile import *
from .forms import ContactForm, ImportXMLForm, TranscribeForm
from django.core.mail import EmailMessage, send_mail
from django.views.generic import ListView, DetailView
from django.urls import reverse


def historicalbackground (request):
    return render(request, 'historicalbackground.html')

def organizations(request):
    return render(request, 'organizations.html')

您可能没有将 MIDDLEWARE_CLASSES 更改为 MIDDLEWARE,因此从 /historicalbackground/historicalbackground/ 的重定向无效。有关详细信息,请参阅

从 Django 1.8.x 到 2.0.x 的跳跃太大了。你错过了所有的弃用警告,所以你会得到这样的奇怪行为。让你的项目在 Django 1 上运行。11.x 没有弃用警告,然后升级到 Django 2.0 会更顺利。