我想获得这个Django项目的帮助。我正在尝试获取帖子数。
def newQuestion(request):
template = "ask_question.html"
form = askQuestion(request.POST or None)
if form.is_valid():
instance = form.save(commit=False)
instance.author = request.user
instance.save()
return redirect("/")
else:
form = askQuestion()
context = {"form": form}
return render(request, template, context)
答案 0 :(得分:3)
如果模型名称为“ Question”,则可以尝试类似的操作
question_count = Question.objects.count()