这些错误在您进入管理页面时发生。我想解决这个问题。帮我。 问题enter image description here
urls.py-fistsite
from django.contrib import admin
from django.urls import path, include
from polls import views
urlpatterns = [
path('', views.index, name='index'),
path('/polls', include('polls.urls')),
path('/admin', include('polls.urls'))
]
urls.py-polls
from django.urls import path
from . import views
app_name = 'polls'
urlpatterns = [
path('', views.index, name='index'),
path('<int:question_id>/', views.detail, name='detail'),
path('<int:question_id>/result/', views.results, name='results'),
path('<int:question_id>/vote/', views.vote, name='vote')
]
答案 0 :(得分:1)
将您的urls.py更改为此,它应该可以工作。
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls), # add this
path('', views.index, name='index'),
]
由于某种原因,您将站点管理员的URL更改为include('polls.urls')
,这是错误的。将其更改回path('admin/', admin.site.urls)
,然后django将其拾取。另外,您不必添加/
django有一个自动执行的中间件。