Code

Ticket #6946: databrowse-sort-models.diff

File databrowse-sort-models.diff, 865 bytes (added by adamv, 3 years ago)

Updated patch; doesn't need 2.3 compatibility anymore (Django 1.3)

Line 
1diff --git a/django/contrib/databrowse/sites.py b/django/contrib/databrowse/sites.py
2index 172ca52..13d44e9 100644
3--- a/django/contrib/databrowse/sites.py
4+++ b/django/contrib/databrowse/sites.py
5@@ -122,7 +122,10 @@ class DatabrowseSite(object):
6         raise http.Http404('The requested databrowse page does not exist.')
7 
8     def index(self, request):
9-        m_list = [EasyModel(self, m) for m in self.registry.keys()]
10+        # Sort by name, case insensitive. Python 2.4 compatible.
11+        sorted_keys = [m for m in self.registry.keys()]
12+        sorted_keys.sort(key = lambda x: x.__name__.upper())
13+        m_list = [EasyModel(self, m) for m in sorted_keys]
14         return render_to_response('databrowse/homepage.html', {'model_list': m_list, 'root_url': self.root_url})
15 
16     def model_page(self, request, app_label, model_name, rest_of_url=None):