1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Fixed #26039 -- Unwrapped nested partials in URL reversal.

Prior to Python 3.5 nested partials need to be fully "unfolded"
to get the actual function.
This commit is contained in:
Grégory Starck
2016-01-05 16:47:48 -05:00
committed by Tim Graham
parent 632a9f21bc
commit 9f9921e89c
3 changed files with 7 additions and 5 deletions

View File

@@ -135,7 +135,9 @@ class RegexURLPattern(LocaleRegexProvider):
'path.to.ClassBasedView').
"""
callback = self.callback
if isinstance(callback, functools.partial):
# Python 3.5 collapses nested partials, so can change "while" to "if"
# when it's the minimum supported version.
while isinstance(callback, functools.partial):
callback = callback.func
if not hasattr(callback, '__name__'):
return callback.__module__ + "." + callback.__class__.__name__