我正尝试将链接添加到Django管理页面,但不会加载带有此链接的页面,因为引发了“ django.urls.exceptions.NoReverseMatch:未找到'admin'的反向字符。'admin'不是有效的视图功能或模式名称。”
Django v2.2.1
urls.py:
from django.conf.urls import url
from django.contrib import admin
from django.urls import path
from MyApp import views
urlpatterns = [
path('', views.index, name='index'),
path('admin/', admin.site.urls, name='admin'),
url(r'^login/$', views.LoginFormView.as_view(), name='login'),
url(r'^logout/$', views.LogoutView.as_view(), name='logout'),
]
index.html:
<a href="{% url 'admin' %}">
<div class="menu-btn">admin</div>
</a>