# A distinct query is not strictly necessary. TODO: benchmark the efficiency
# with/without distinct.
- targets = list(Node.objects.filter(pk__in=target_pks).distinct())
+ targets = dict([(n.pk, n) for n in Node.objects.filter(pk__in=target_pks).distinct()])
for cache in caches:
for item in cache['items']:
if item.target_node_id:
- item.target_node = targets[targets.index(item.target_node)]
+ item.target_node = targets[item.target_node_id]
def clear_cache(self):
"""Clears the manager's entire navigation cache."""
@property
def accepts_subpath(self):
"""A property shortcut for :attr:`self.view.accepts_subpath <View.accepts_subpath>`"""
- if self.view:
- return self.view.accepts_subpath
+ if self.view_object_id and self.view_content_type_id:
+ return ContentType.objects.get_for_id(self.view_content_type_id).model_class().accepts_subpath
return False
def handles_subpath(self, subpath):
#: A generic relation back to nodes.
nodes = generic.GenericRelation(Node, content_type_field='view_content_type', object_id_field='view_object_id')
- #: Property or attribute which defines whether this :class:`View` can handle subpaths. Default: ``False``
+ #: An attribute on the class which defines whether this :class:`View` can handle subpaths. Default: ``False``
accepts_subpath = False
def handles_subpath(self, subpath):
if self.with_obj is None and self.view_name is None:
url = node.get_absolute_url()
else:
- if not node.view.accepts_subpath:
+ if not node.accepts_subpath:
return settings.TEMPLATE_STRING_IF_INVALID
if self.with_obj is not None: