def get_admin_index(app):
 from django.utils.text import capfirst
 from django.db.models import get_models
 output = []
 app_models = get_models(app)
 app_label = app_models[0]._meta.app_label
 output.append(('{%% if perms.%s %%}' % app_label))
 output.append(('<div class="module"><h2>%s</h2><table>' % app_label.title()))
 for model in app_models:
  if model._meta.admin:
   output.append((MODULE_TEMPLATE % {'app': app_label, 'mod': model._meta.module_name, 'name': capfirst(model._meta.verbose_name_plural), 'addperm': model._meta.get_add_permission(), 'changeperm': model._meta.get_change_permission()}))
 output.append('</table></div>')
 output.append('{% endif %}')
 return output

def get_admin_index ( app ) : from django . utils . text import capfirst from django . db . models import get_models output = [ ] app_models = get_models ( app ) app_label = app_models [ 0 ] . _meta . app_label output . append ( ( '{%% if perms.%s %%}' % app_label ) ) output . append ( ( '<div class="module"><h2>%s</h2><table>' % app_label . title ( ) ) ) for model in app_models : if model . _meta . admin : output . append ( ( MODULE_TEMPLATE % { 'app' : app_label , 'mod' : model . _meta . module_name , 'name' : capfirst ( model . _meta . verbose_name_plural ) , 'addperm' : model . _meta . get_add_permission ( ) , 'changeperm' : model . _meta . get_change_permission ( ) } ) ) output . append ( '</table></div>' ) output . append ( '{% endif %}' ) return output
returns admin-index template snippet for the given app .