enter code here
TypeError在/ polls /
join()参数必须是str,字节或os.PathLike对象,而不是“函数”
请求方法:GET
要求网址:http://127.0.0.1:8000/polls/
Django版本:3.1
异常类型:TypeError
异常值:
join()参数必须是str,字节或os.PathLike对象,而不是“函数”
例外位置:c:\ users \ lenovo \ appdata \ local \ programs \ python \ python38-32 \ lib \ genericpath.py,第152行,以_check_arg_types
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse,HttpResponseRedirect
from django.urls import reverse
from .models import Question, choice
# Create your views here.
def index(request):
latest_question_list = Question.objects.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, detail,{'question': question})
def results(request, question_id):
question = get_object_or_404(Question, pk=question_id)
return render(request, 'polls/result.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.vote += 1
selected_choice.save()
return HttpResponseRedirect(reverse('polls:result', args=(question.id,)))
答案 0 :(得分:0)
在您认为负责处理“轮询”端点的某个位置,您正在导致在函数对象上调用字符串连接方法。请发布您的源代码和完整堆栈跟踪。