diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-11-29 18:45:39 -0500 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-12-01 20:48:54 -0500 |
| commit | 34186e731ca20a2344b1f88fd543a854d6b13a00 (patch) | |
| tree | c9d993b6a358540bbf6b42b298507b2f1aa8f364 /django/contrib/admin | |
| parent | ce36c35e76f82f76cdfa5777456e794d481e5afc (diff) | |
Fixed #36712 -- Evaluated type annotations lazily in template tag registration.
Ideally, this will be reverted when an upstream solution is available for
https://github.com/python/cpython/issues/141560.
Thanks Patrick Rauscher for the report and Augusto Pontes for the
first iteration and test.
Diffstat (limited to 'django/contrib/admin')
| -rw-r--r-- | django/contrib/admin/templatetags/base.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/django/contrib/admin/templatetags/base.py b/django/contrib/admin/templatetags/base.py index 9551c0e71d..3f8290d3b1 100644 --- a/django/contrib/admin/templatetags/base.py +++ b/django/contrib/admin/templatetags/base.py @@ -1,6 +1,7 @@ from inspect import getfullargspec from django.template.library import InclusionNode, parse_bits +from django.utils.inspect import lazy_annotations class InclusionAdminNode(InclusionNode): @@ -11,9 +12,10 @@ class InclusionAdminNode(InclusionNode): def __init__(self, parser, token, func, template_name, takes_context=True): self.template_name = template_name - params, varargs, varkw, defaults, kwonly, kwonly_defaults, _ = getfullargspec( - func - ) + with lazy_annotations(): + params, varargs, varkw, defaults, kwonly, kwonly_defaults, _ = ( + getfullargspec(func) + ) bits = token.split_contents() args, kwargs = parse_bits( parser, |
