def root(cls):
site = Site.objects.get_current()
root_nodes = list(
cls.objects.root_nodes().filter(site=site).select_related_common()
)
# We fetch the nodes as a list and use len(), not count() because we need
# to get the result out anyway. This only takes one sql query
no_paths = len(root_nodes)
if no_paths == 0:
raise NoRootURL(
"You need to create a root article on site '%s'" %
site)
if no_paths > 1:
raise MultipleRootURLs(
"Somehow you have multiple roots on %s" %
site)
return root_nodes[0]
评论列表
文章目录