From 1b22d53bf67943cd193bbd6e327d955c19d2f5d2 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Fri, 27 Feb 2026 14:43:55 -0500 Subject: [6.0.x] Fixed #36961 -- Fixed TypeError in deprecation warnings if Django is imported by namespace. Backport of c1d8646ec219b8b90ebdd463f40e5767876658a0 from main. --- django/utils/deprecation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'django') diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py index eea24cf94b..11a37f05bc 100644 --- a/django/utils/deprecation.py +++ b/django/utils/deprecation.py @@ -12,9 +12,8 @@ from django.utils.inspect import signature @functools.cache def django_file_prefixes(): - try: - file = django.__file__ - except AttributeError: + file = getattr(django, "__file__", None) + if file is None: return () return (os.path.dirname(file),) -- cgit v1.3