def extract_views_from_urlpatterns(urlpatterns, base=''):
 views = []
 for p in urlpatterns:
  if hasattr(p, '_get_callback'):
   try:
    views.append((p._get_callback(), (base + p.regex.pattern)))
   except ViewDoesNotExist:
    continue
  elif hasattr(p, '_get_url_patterns'):
   try:
    patterns = p.url_patterns
   except ImportError:
    continue
   views.extend(extract_views_from_urlpatterns(patterns, (base + p.regex.pattern)))
  else:
   raise TypeError((_('%s does not appear to be a urlpattern object') % p))
 return views

def extract_views_from_urlpatterns ( urlpatterns , base = '' ) : views = [ ] for p in urlpatterns : if hasattr ( p , '_get_callback' ) : try : views . append ( ( p . _get_callback ( ) , ( base + p . regex . pattern ) ) ) except ViewDoesNotExist : continue elif hasattr ( p , '_get_url_patterns' ) : try : patterns = p . url_patterns except ImportError : continue views . extend ( extract_views_from_urlpatterns ( patterns , ( base + p . regex . pattern ) ) ) else : raise TypeError ( ( _ ( '%s does not appear to be a urlpattern object' ) % p ) ) return views
return a list of views from a list of urlpatterns .