Ticket #4326: django_new_admin_2_bug_fixed.patch
File django_new_admin_2_bug_fixed.patch, 2.5 KB (added by , 18 years ago) |
---|
-
django/contrib/admin/sites.py
2 2 from django.contrib.admin import ModelAdmin 3 3 from django.contrib.auth import authenticate, login 4 4 from django.db.models import Model 5 from django.db.models.base import ModelBase 5 6 from django.shortcuts import render_to_response 6 7 from django.utils.text import capfirst 7 8 from django.utils.translation import gettext_lazy 9 from django.utils.datastructures import SortedDict 8 10 import base64 9 11 import cPickle as pickle 10 12 import datetime … … 69 71 """ 70 72 admin_class = admin_class or ModelAdmin 71 73 # TODO: Handle options 72 if is subclass(model_or_iterable, Model):74 if isinstance(model_or_iterable, ModelBase) and issubclass(model_or_iterable, Model): 73 75 model_or_iterable = [model_or_iterable] 74 76 for model in model_or_iterable: 75 77 if model in self._registry: … … 234 236 Displays the main admin index page, which lists all of the installed 235 237 apps that have been registered in this site. 236 238 """ 237 app _list = []239 apps = SortedDict() 238 240 user = request.user 239 241 for model, model_admin in self._registry.items(): 240 242 app_label = model._meta.app_label … … 254 256 'admin_url': '%s/%s/' % (app_label, model.__name__.lower()), 255 257 'perms': perms, 256 258 } 257 app_list.append({ 258 'name': app_label.title(), 259 'has_module_perms': has_module_perms, 260 'models': [model_dict], 261 }) 259 if app_label in apps: 260 apps[app_label]['models'].append(model_dict) 261 else: 262 apps[app_label] = { 263 'name': app_label.title(), 264 # I found that this isn't used in template. 265 #'has_module_perms': has_module_perms, 266 'models': [model_dict], 267 } 262 268 return render_to_response('admin/index.html', { 263 269 'title': _('Site administration'), 264 'app_list': app _list,270 'app_list': apps.values(), 265 271 }, context_instance=template.RequestContext(request)) 266 272 267 273 # This global object represents the default admin site, for the common case.