Opened 7 years ago

Closed 6 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 7 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by badri

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to badri
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Changed 7 years ago by badri

comment:2 Changed 7 years ago by badri

  • Has patch set

comment:3 Changed 7 years ago by mathijs

  • Needs documentation set
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Accepted to Design 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 Changed 7 years ago by ramiro

  • Triage Stage changed from Design decision needed to Unreviewed

See also #7497 for a related proposal/discussion.

comment:5 Changed 7 years ago by jacob

  • Triage Stage changed from Unreviewed to Design decision needed

comment:6 Changed 6 years ago by sampablokuper

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 Changed 6 years ago by sampablokuper

  • 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 Changed 6 years ago by russellm

  • Resolution set to duplicate
  • Status changed from assigned to closed

Duplicate of #7497.

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