Add second attempt to match a navigation object as an instance of a source. Use for instances from a queryset using .defer() or .only().

This commit is contained in:
Roberto Rosario
2016-05-12 01:48:42 -04:00
parent 084f6d4b2f
commit 7da6408de0

View File

@@ -136,6 +136,19 @@ class Menu(object):
resolved_links.append(resolved_link)
# No need for further content object match testing
break
else:
# Second try for objects using .defer() or .only()
if inspect.isclass(bound_source) and isinstance(resolved_navigation_object, bound_source):
for link in links:
resolved_link = link.resolve(
context=context,
resolved_object=resolved_navigation_object
)
if resolved_link:
resolved_links.append(resolved_link)
# No need for further content object match testing
break
except TypeError:
# When source is a dictionary
pass