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:
parent
4a80d0f220
commit
0c0b87725b
|
@ -20,6 +20,9 @@ else:
|
||||||
|
|
||||||
|
|
||||||
def get_view_name(view_func):
|
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__
|
mod_name = view_func.__module__
|
||||||
view_name = getattr(view_func, '__qualname__', view_func.__class__.__name__)
|
view_name = getattr(view_func, '__qualname__', view_func.__class__.__name__)
|
||||||
return mod_name + '.' + view_name
|
return mod_name + '.' + view_name
|
||||||
|
|
|
@ -378,7 +378,9 @@ class URLPattern:
|
||||||
callback = self.callback
|
callback = self.callback
|
||||||
if isinstance(callback, functools.partial):
|
if isinstance(callback, functools.partial):
|
||||||
callback = callback.func
|
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.__class__.__name__
|
||||||
return callback.__module__ + "." + callback.__qualname__
|
return callback.__module__ + "." + callback.__qualname__
|
||||||
|
|
||||||
|
|
|
@ -517,7 +517,9 @@ def technical_404_response(request, exception):
|
||||||
else:
|
else:
|
||||||
obj = resolver_match.func
|
obj = resolver_match.func
|
||||||
|
|
||||||
if hasattr(obj, '__name__'):
|
if hasattr(obj, 'view_class'):
|
||||||
|
caller = obj.view_class
|
||||||
|
elif hasattr(obj, '__name__'):
|
||||||
caller = obj.__name__
|
caller = obj.__name__
|
||||||
elif hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
|
elif hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
|
||||||
caller = obj.__class__.__name__
|
caller = obj.__class__.__name__
|
||||||
|
|
Loading…
Reference in New Issue