Opened 17 years ago

Closed 13 years ago

#6946 closed New feature (wontfix)

Alphabetize DatabrowseSite index view

Reported by: anonymous Owned by: nobody
Component: contrib.databrowse Version: dev
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 17 years ago.
6946_python23.diff (692 bytes ) - added by Michael Axiak 17 years ago.
Python2.3 compatible
databrowse-sort-models.diff (865 bytes ) - added by Adam Vandenberg 14 years ago.
Updated patch; doesn't need 2.3 compatibility anymore (Django 1.3)

Download all attachments as: .zip

Change History (10)

comment:1 by Michael Axiak, 17 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

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

by cstejerean, 17 years ago

Attachment: 6946.patch added

comment:2 by cstejerean, 17 years ago

Needs tests: set

comment:3 by cstejerean, 17 years ago

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.

in reply to:  3 comment:4 by Michael Axiak, 17 years ago

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?

by Michael Axiak, 17 years ago

Attachment: 6946_python23.diff added

Python2.3 compatible

comment:5 by anonymous, 17 years ago

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] 

by Adam Vandenberg, 14 years ago

Attachment: databrowse-sort-models.diff added

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

comment:6 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:7 by Preston Holmes, 13 years ago

Easy pickings: unset
Resolution: wontfix
Status: newclosed
UI/UX: unset

Databrowse is now deprecated, see #16907

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