我已经从Django 1.9.7升级到Django 2.2。
渲染视图时,出现以下错误-
'NoneType' object has no attribute 'render_context'
View -
@login_required
def query_store_admin(request):
template_name = "query_store/query_store_overview.html" ##
print(template_name)
return render(request, template_name)
Traceback -
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/query_store/query_store_admin
Django Version: 2.2.6
Python Version: 3.6.8
Traceback:
File "/home/pgp/Desktop/Env/env/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/pgp/Desktop/Env/env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/home/pgp/Desktop/Env/env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python3.6/contextlib.py" in inner
52. return func(*args, **kwds)
File "/home/pgp/Desktop/Env/env/lib/python3.6/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)
File "/home/pgp/Desktop/Clickwork/query_store/views.py" in query_store_admin
185. return render(request, template_name)
File "/home/pgp/Desktop/Env/env/lib/python3.6/site-packages/django/shortcuts.py" in render
36. content = loader.render_to_string(template_name, context, request, using=using)
File "/home/pgp/Desktop/Env/env/lib/python3.6/site-packages/django/template/loader.py" in render_to_string
62. return template.render(context, request)
File "/home/pgp/Desktop/Env/env/lib/python3.6/site-packages/django/template/backends/django.py" in render
62. return self.template.render(context)
File "/home/pgp/Desktop/Env/env/lib/python3.6/site-packages/django/template/base.py" in render
167. with context.render_context.push_state(self):
Exception Type: AttributeError at /query_store/query_store_admin
Exception Value: 'NoneType' object has no attribute 'render_context'
我从网络上尝试了很多东西,但这没有帮助。有人可以让我了解在这里实际需要做什么。