gpt4 book ai didi

django - 发生 VsCode 异常 : VariableDoesNotExist

转载 作者:行者123 更新时间:2023-12-04 17:42:55 28 4
gpt4 key购买 nike

VS Code 在使用调试器运行 Django 时抛出异常。

我在之前运行良好的两个不同项目上遇到了同样的问题。我不记得任何会导致此异常的更改。当我尝试打开 Django 管理页面时会发生这种情况。

异常(exception):

Exception has occurred: VariableDoesNotExist
Failed lookup for key [is_popup] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: '1XjSoBrvAaFZuOY9WTme5tXLO8awl43ORBO5YolUoHOlM0nOLDAfGd0atO3kh3dI'>, 'debug': True, 'sql_queries': <function debug.<locals>.<lambda> at 0x109638c80>, 'request': <WSGIRequest: GET '/login/?next=/'>, 'user': <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x1095d3908>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x1095d3550>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x1095d3c50>, '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 0x1095d3940>, 'site_title': 'Administration', 'site_header': 'Meridia ETL', 'site_url': '/', 'has_permission': False, 'available_apps': [], 'title': 'Log in', 'app_path': '/login/?next=/', 'username': '', 'next': '/', 'site': <django.contrib.sites.requests.RequestSite object at 0x1095d35f8>, 'site_name': 'localhost:8000', 'LANGUAGE_CODE': 'en-us', 'LANGUAGE_BIDI': False}]
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/base.py", line 850, in _resolve_lookup
(bit, current)) # missing attribute
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/base.py", line 796, in resolve
value = self._resolve_lookup(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/base.py", line 671, in resolve
obj = self.var.resolve(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/defaulttags.py", line 875, in eval
return self.value.resolve(context, ignore_failures=True)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/defaulttags.py", line 302, in render
match = condition.eval(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "/Users/macbook/Development/MERIDIA/meridiaETLproject/env/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render

仅当我将 Debugger 与这些 Launch.json 设置一起使用时才会发生这种情况:
{
"name": "Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"--noreload",
// "--nothreading",
// "--settings=bouncer.settings.development"
],
"django": true
}

它在 python manage.py runserver 上运行良好

操作系统: MacOS Mojave 10.14
Django : 2.1.1
VS代码: 1.32.3

最佳答案

似乎调试器仅在默认断点 Uncaught Exception 时抛出异常被检查。

enter image description here

所以解决方法就是让它不被选中。

关于django - 发生 VsCode 异常 : VariableDoesNotExist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55490742/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com