@assignment_tag(takes_context=True)
def test_page_is_public(context, page):
 if (u'all_page_view_restriction_paths' not in context):
  context[u'all_page_view_restriction_paths'] = PageViewRestriction.objects.select_related(u'page').values_list(u'page__path', flat=True)
 is_private = any([page.path.startswith(restricted_path) for restricted_path in context[u'all_page_view_restriction_paths']])
 return (not is_private)

@ assignment_tag ( takes_context = True ) def test_page_is_public ( context , page ) : if ( u'all_page_view_restriction_paths' not in context ) : context [ u'all_page_view_restriction_paths' ] = PageViewRestriction . objects . select_related ( u'page' ) . values_list ( u'page__path' , flat = True ) is_private = any ( [ page . path . startswith ( restricted_path ) for restricted_path in context [ u'all_page_view_restriction_paths' ] ] ) return ( not is_private )
usage: {% test_page_is_public page as is_public %} sets is_public to true iff there are no page view restrictions in place on this page .