Opened 7 years ago

Closed 4 years ago

#6946 closed New feature (wontfix)

Alphabetize DatabrowseSite index view

Reported by: anonymous Owned by: nobody
Component: contrib.databrowse Version: master
Severity: Normal Keywords: alphabetize, index
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

In sites with a lot of models, it would be helpful if the DatabrowseSite index view were alphabetized:

  • django/contrib/databrowse/sites.py

     
    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        m_list = [EasyModel(self, m) for m in sorted(self.registry.keys(), lambda x,y:cmp(x.__name__,y.__name__))]
    126126        return render_to_response('databrowse/homepage.html', {'model_list': m_list, 'root_url': self.root_url})
    127127
    128128    def model_page(self, request, app_label, model_name, rest_of_url=None):

Attachments (3)

6946.patch (1.1 KB) - added by cstejerean 7 years ago.
6946_python23.diff (692 bytes) - added by axiak 7 years ago.
Python2.3 compatible
databrowse-sort-models.diff (865 bytes) - added by adamv 5 years ago.
Updated patch; doesn't need 2.3 compatibility anymore (Django 1.3)

Download all attachments as: .zip

Change History (10)

comment:1 Changed 7 years ago by axiak

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

I think this is useful...however sorted is a python 2.5-ism and people will probably complain that it's case sensitive.

Changed 7 years ago by cstejerean

comment:2 Changed 7 years ago by cstejerean

  • Needs tests set

comment:3 follow-up: Changed 7 years ago by cstejerean

the attached patch should sort case insensitive and should also be compatible with python2.4
I can't figure out how to run the Django unit tests (can't seem to get all the right settings) so a test is not included.

comment:4 in reply to: ↑ 3 Changed 7 years ago by axiak

Replying to cstejerean:

the attached patch should sort case insensitive and should also be compatible with python2.4

Except now it isn't compatible with python2.3. Why not do what's outlined in the following patch?

Changed 7 years ago by axiak

Python2.3 compatible

comment:5 Changed 7 years ago by anonymous

is this any nicer?

        if float(sys.version[:3]) >= 2.4:
            m_list.sort(key=str.lower)
        else:
            m_list = [(x.__name__.lower(), x) for x in m_list] 
            m_list.sort() 
            m_list = [x[1] for x in m_list] 

Changed 5 years ago by adamv

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

comment:6 Changed 4 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:7 Changed 4 years ago by ptone

  • Easy pickings unset
  • Resolution set to wontfix
  • Status changed from new to closed
  • UI/UX unset

Databrowse is now deprecated, see #16907

Note: See TracTickets for help on using tickets.
Back to Top