Ticket #6946: 6946.patch

File 6946.patch, 1.1 KB (added by cstejerean, 17 years ago)
  • django/contrib/databrowse/sites.py

    diff --git a/django/contrib/databrowse/sites.py b/django/contrib/databrowse/sites.py
    index 5d8c1c8..d33a00c 100644
    a b class DatabrowseSite(object):  
    122122        raise http.Http404('The requested databrowse page does not exist.')
    123123
    124124    def index(self, request):
    125         m_list = [EasyModel(self, m) for m in self.registry.keys()]
     125        # sort by name, using case insensitive sorting
     126        if 'sorted' in __builtins__.__dict__: #python2.5
     127            m_list = [EasyModel(self, m) for m in sorted(self.registry.keys(), key = lambda x: x.__name__.upper())]
     128        else: #python2.4 compatibility
     129            sorted_keys = [m for m in self.registry.keys()]
     130            sorted_keys.sort(key = lambda x: x.__name__.upper())
     131            m_list = [EasyModel(self, m) for m in sorted_keys]
    126132        return render_to_response('databrowse/homepage.html', {'model_list': m_list, 'root_url': self.root_url})
    127133
    128134    def model_page(self, request, app_label, model_name, rest_of_url=None):
Back to Top