Python 我想在Django解决这个错误

Python 我想在Django解决这个错误,python,django,webserver,Python,Django,Webserver,今年秋天我还没有解决。我不知道这个错误是什么意思。请修复此错误 问题: 源代码 url.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', views.polls, name='pol

今年秋天我还没有解决。我不知道这个错误是什么意思。请修复此错误

问题: 源代码 url.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', views.polls, name='polls'),
    path('/admin', views.admin, name='admin')
]
url.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')
]
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect, HttpResponse
from django.urls import reverse
from polls.models import Question, Choice

# Create your views here.
def index(request):
    latest_question_list = Question.objects.all().order_by('-pub_date')[:5]
    context = {'latest_question_list':latest_question_list}
    return render(request, 'polls/index.html', context)

def detail(request, question_id):
    question = get_object_or_404(Question, pk=question_id)
    return render(request, 'polls/detail.html', {'question': question})

def vote(request, question_id):
    question = get_object_or_404(Question, pk=question_id)
    try:
        selected_choice = question.choice.set.get(pk=request.POST['choice'])
    except (KeyError, Choice.DoesNotExist):
        return render(request, 'polls/detail.html',{
            'question': question,
            'error_message': "You didn't select a choice.",
        })
    else:
        selected_choice.votes += 1
        selected_choice.save()
        return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))

def results(request, question_id):
    question = get_object_or_404(Question, pk=question_id)
    return render(request, 'polls/result.html', {'question': question})

这里的问题是您使用的是views.polls,但在您的views.py中,您有索引、详细信息、投票和结果。views.py中没有民意测验。 相反,您需要包括polls应用程序中存在的所有urlpatterns

urlpatterns = [
    path('polls/', include('polls.urls')),
    path('admin/', views.admin, name='admin'),
]
把官方文件重新检查一遍

urlpatterns = [
    path('polls/', include('polls.urls')),
    path('admin/', views.admin, name='admin'),
]