升级Django后,在/ admin /处出现NoReverseMatch错误

时间:2018-07-02 18:54:14

标签: django django-admin django-upgrade

将Django项目从1.8升级到2.0后,我尝试登录到管理页面,并收到此错误消息。我可以看到登录页面以及其他管理员链接,例如“ http://159.203.172.178/admin/QI/page/”,但我只能看到首页。admin error picture link

我肯定在这里包括太多代码,因为我现在确实不在问题所在。预先非常感谢。

用于管理员的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
from django.urls import path,re_path,reverse,include

app_name="QI"

urlpatterns = [
    path('admin/', admin.site.urls),
]

settings.py:

 import os
 from .settings_secret import *

 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

 STATIC_URL = '/static/'

 STATIC_ROOT = os.path.join(BASE_DIR, 'static')

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# Application definition

 INSTALLED_APPS = (
   'django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'import_export',
   'xml_tool',
   'haystack',
   'QI',
)

 MIDDLEWARE = (
    'django.middleware.security.SecurityMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',)

ROOT_URLCONF = 'QI.urls'

TEMPLATES = [
   {
       'BACKEND': 'django.template.backends.django.DjangoTemplates',
       'DIRS': [os.path.join(BASE_DIR, 'templates')],
       'APP_DIRS': True,
       'OPTIONS': {
           'context_processors': [
               'django.template.context_processors.debug',
               'django.template.context_processors.request',
               'django.template.context_processors.static',
               'django.contrib.auth.context_processors.auth',
               'django.contrib.messages.context_processors.messages',

此html文件中包含的review_transcription_lists:

{% extends 'admin/base_site.html' %}

{% load staticfiles %}


{% block extrastyle %}
<link rel="stylesheet" href="{% static 'admin/css/forms.css' %}">
<link rel="stylesheet" href="{% static 'admin/css/widgets.css' %}">
{% endblock %}

{% block content %}
<div id="content-main">
   <h1>All Unapproved Transcriptions</h1>
   <table>
   <thead>
     <tr>
     <th>Manuscript</th>
     <th>Date Transcribed</th>
     <th>Author</th>
   </tr>
  </thead>
 <tbody>
 {% for transcription in object_list %}
 <tr>
    <td><a href="/admin/review_transcriptions/{{ transcription.doc.id_tei }}">{{ transcription.doc.id_tei }}</a></td>
    <td>{{ transcription.uploaded }}</td>
    <td>{{ transcription.name }}</td>
 </tr>
 {% endfor %}
</table>
</div>

0 个答案:

没有答案