@register.filter
def all_ancestors_are_published(page, language):
 page = page.parent
 while page:
  if (not page.is_published(language)):
   return False
  page = page.parent
 return True

@ register . filter def all_ancestors_are_published ( page , language ) : page = page . parent while page : if ( not page . is_published ( language ) ) : return False page = page . parent return True
returns false if any of the ancestors of page are unpublished .