VS Code throws exception when using debugger to run Django.
I got the same problem on two different projects that were working fine before. I can't recall any changes that would lead to this exception. It occurs when I try to open Django admin page.
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
It only happens when I use Debugger with these Launch.json settings:
{
"name": "Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"--noreload",
// "--nothreading",
// "--settings=bouncer.settings.development"
],
"django": true
}
It does work fine with python manage.py runserver
OS: MacOS Mojave 10.14
Django: 2.1.1
VS Code: 1.32.3
Seems like Debugger throws exception only when a default breakpoint Uncaught Exception
is checked.
So workaround would be just to make it unchecked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With