Opened 15 years ago

Closed 15 years ago

#9928 closed (duplicate)

Ordering of admin.ModelAdmin objects in admin site

Reported by: ruiaf Owned by: Badri
Component: contrib.admin Version: 1.0
Severity: Keywords:
Cc: sam.kuper@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: UI/UX:

Description

Lets say I have my pizza application with Topping and Pizza classes and they show in Django Admin like this:

Toppings Add / Change
Pizzas Add / Change

But it would be nice to have them like this:

Pizzas Add / Change
Toppings Add / Change

Currently there is no way of doing this. It would be nice and I think it is important.

Attachments (1)

9928.diff (2.1 KB ) - added by Badri 15 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by Badri, 15 years ago

Owner: changed from nobody to Badri
Status: newassigned
Triage Stage: UnreviewedAccepted

by Badri, 15 years ago

Attachment: 9928.diff added

comment:2 by Badri, 15 years ago

Has patch: set

comment:3 by Mathijs Dumon, 15 years ago

Needs documentation: set
Needs tests: set
Patch needs improvement: set
Triage Stage: AcceptedDesign decision needed

I think this should be improved as such that we can set an 'index' field on our ModelAdmin objects and our applications. If it is present this is used for ordering, if not alphabetical ordering is assumed. This index field is trivial for ModelAdmin objects, but for application it should be set inside the admin.py file, perhaps like this:

#...
INDEX = 1
#...

this way users have full control over ordering inside apps and outside apps, eg. the index page would look like:

app 1

model 1
model 3
model 4

app 2

model 1
model 2
model 4
model 5

where the number is value of the index property

comment:4 by Ramiro Morales, 15 years ago

Triage Stage: Design decision neededUnreviewed

See also #7497 for a related proposal/discussion.

comment:5 by Jacob, 15 years ago

Triage Stage: UnreviewedDesign decision needed

comment:6 by sampablokuper, 15 years ago

If I'm not mistaken, at the moment the ordering depends on the order in which the models are defined in your models.py for the app. So by re-ordering them there, you can change the order in which they're shown in the admin.

However, it may not always be possible to place them in the desired order in models.py, for instance if the model you want at the beginning of the list in the admin depends on having something defined by another model in the same app. So although the above workaround will be useful in some cases, a proper fix is still needed.

comment:7 by sampablokuper, 15 years ago

Cc: sam.kuper@… added

NB. I could well be mistaken about the workaround I suggested. It's based on a very hazy recollection and nothing more.

comment:8 by Russell Keith-Magee, 15 years ago

Resolution: duplicate
Status: assignedclosed

Duplicate of #7497.

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