所以基本上我有一个模板上下文处理器,如下所示:
def tests_context(request):
tests = Test.objects.filter(group=request.user.group)
users_tests = CompletedTest.objects.filter(user=request.user)
categories = Category.objects.all()
categories_tests = {}
for category in categories:
categories_tests[category] = Test.objects.filter(category=category).filter(group=request.user.group)
return {"categories_tests": categories_tests, "users_tests": users_tests}
我将此函数添加到settings.py中的TEMPLATE_CONTEXT_PROCESSORS:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.request"
"tests.views.tests_context",
)
它不起作用。它甚至没有调用此函数功能。我的应用程序名为测试。为什么django甚至没有调用这个函数?可能是因为应用名称?我该如何解决呢。