1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #32260 -- Made admindocs and technical 404 debug page use view_func.view_class.

Internals of admindocs and technical 404 debug page should use the
view_class attribute and do not rely on __name__.
This commit is contained in:
Adam Johnson 2021-03-17 10:55:00 +00:00 committed by Mariusz Felisiak
parent 4a80d0f220
commit 0c0b87725b
3 changed files with 9 additions and 2 deletions

View File

@ -20,6 +20,9 @@ else:
def get_view_name(view_func):
if hasattr(view_func, 'view_class'):
klass = view_func.view_class
return f'{klass.__module__}.{klass.__qualname__}'
mod_name = view_func.__module__
view_name = getattr(view_func, '__qualname__', view_func.__class__.__name__)
return mod_name + '.' + view_name

View File

@ -378,7 +378,9 @@ class URLPattern:
callback = self.callback
if isinstance(callback, functools.partial):
callback = callback.func
if not hasattr(callback, '__name__'):
if hasattr(callback, 'view_class'):
callback = callback.view_class
elif not hasattr(callback, '__name__'):
return callback.__module__ + "." + callback.__class__.__name__
return callback.__module__ + "." + callback.__qualname__

View File

@ -517,7 +517,9 @@ def technical_404_response(request, exception):
else:
obj = resolver_match.func
if hasattr(obj, '__name__'):
if hasattr(obj, 'view_class'):
caller = obj.view_class
elif hasattr(obj, '__name__'):
caller = obj.__name__
elif hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
caller = obj.__class__.__name__