Ticket #4258: admin-index.diff

File admin-index.diff, 1.5 KB (added by Matthias Pronk <django@…>, 17 years ago)
  • django/contrib/admin/sites.py

     
    254254                        'admin_url': '%s/%s/' % (app_label, model.__name__.lower()),
    255255                        'perms': perms,
    256256                    }
    257                     app_list.append({
    258                         'name': app_label.title(),
    259                         'has_module_perms': has_module_perms,
    260                         'models': [model_dict],
    261                     })
     257                   
     258                    existing_app = False
     259                    for app in app_list:
     260                        if app['name'] == app_label.title():
     261                            app['models'].append(model_dict)
     262                            existing_app = True
     263                    if not existing_app:
     264                        app_list.append({
     265                            'name': app_label.title(),
     266                            'has_module_perms': has_module_perms,
     267                            'models': [model_dict],
     268                        })
     269
     270        # Sort apps and models
     271        app_list.sort(lambda x, y: cmp(x['name'], y['name']))
     272        for app in app_list:
     273            app['models'].sort(lambda x, y: cmp(x['name'], y['name']))
     274           
    262275        return render_to_response('admin/index.html', {
    263276            'title': _('Site administration'),
    264277            'app_list': app_list,
Back to Top