-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django.template.base.VariableDoesNotExist: Failed lookup for key [script_url] #1159
Comments
SERVER_ENV=local ./manage.py spectacular --file schema.yaml --validate |
Hi, this is highly unusual. I'm not even sure how it is possible that line 22 produces an error. By definition the
|
@copyNdpaste do you have Django Debug Toolbar installed? I run into these errors when the Toolbar is visible. |
This is just a debug level log from the 'django' logger, it logs the exception but replaces the variable with context.template.engine.string_if_invalid, which is an empty string by default, so there are no errors in request or templates rendering. ...
except Exception as e:
template_name = getattr(context, "template_name", None) or "unknown"
logger.debug(
"Exception while resolving variable '%s' in template '%s'.",
bit,
template_name,
exc_info=True,
)
if getattr(e, "silent_variable_failure", False):
current = context.template.engine.string_if_invalid
else:
raise
return current https://docs.djangoproject.com/en/5.0/ref/templates/api/#how-invalid-variables-are-handled |
thx @vcleal this finally makes sense, I believe. Since there is no nice&short way of checking for existence, it is easier to just set this var to I think this should fix it then. Feedback welcome. |
settings.py
urls.py
why VariableDoesNotExist error is raised?
The text was updated successfully, but these errors were encountered: