我正在尝试在vscode中配置django项目并通过调试运行。 python == 3.6.7 Django == 2.1.8
当我尝试打开http://127.0.0.1:8000/admin/时出现以下错误,请参考下面的屏幕截图。
我通过尝试将日志记录级别从调试更改为信息,尝试了Google的许多可能的解决方法,但似乎无济于事。
我请您让我知道如何解决此问题。 预先感谢。
错误日志:
Exception has occurred: VariableDoesNotExist
Failed lookup for key [is_popup] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ff6323e3510>>, 'request': <WSGIRequest: GET '/admin/login/?next=/admin/'>, 'user': <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7ff632434dd8>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7ff6323b2f98>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7ff63246cc88>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}}, {}, {'form': <AdminAuthenticationForm bound=False, valid=Unknown, fields=(username;password)>, 'view': <django.contrib.auth.views.LoginView object at 0x7ff63246cc50>, 'site_title': 'Django site admin', 'site_header': 'Django administration', 'site_url': '/', 'has_permission': False, 'available_apps': [], 'title': 'Log in', 'app_path': '/admin/login/?next=/admin/', 'username': '', 'next': '/admin/', 'site': <django.contrib.sites.requests.RequestSite object at 0x7ff6323f95f8>, 'site_name': '127.0.0.1:8000', 'LANGUAGE_CODE': 'en-us', 'LANGUAGE_BIDI': False}]
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 850, in _resolve_lookup
(bit, current)) # missing attribute
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 796, in resolve
value = self._resolve_lookup(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 671, in resolve
obj = self.var.resolve(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/defaulttags.py", line 875, in eval
return self.value.resolve(context, ignore_failures=True)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/defaulttags.py", line 302, in render
match = condition.eval(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 171, in render
return self._render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/response.py", line 83, in rendered_content
content = template.render(context, self._request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 154, in _get_response
response = response.render()
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 78, in get_response
response = self._middleware_chain(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 142, in __call__
response = self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 65, in __call__
return self.application(environ, start_response)
File "/usr/lib/python3.6/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 169, in handle
self.handle_one_request()
File "/usr/lib/python3.6/socketserver.py", line 721, in __init__
self.handle()
File "/usr/lib/python3.6/socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.6/socketserver.py", line 348, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python3.6/socketserver.py", line 317, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python3.6/socketserver.py", line 238, in serve_forever
self._handle_request_noblock()
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 213, in run
httpd.serve_forever()
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 139, in inner_run
ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 104, in run
self.inner_run(None, **options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/fs052/Desktop/workspace/tryouts/dj2/dj2/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib/python3.6/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
答案 0 :(得分:0)
似乎您的django安装已损坏。尝试这个
pip install -I django