Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#21534 closed New feature (worksforme)

Admin List Widgets Need To Be Paginated

Reported by: gabreyla@… Owned by: nobody
Component: contrib.admin Version: 1.6
Severity: Normal Keywords: Admin, Lots of Data, Paginated Widgets
Cc: gabreyla@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes


I connected the Django ORM to an existing postgresDB (which we used to use sqlAlchemy to manage/use) and has a lot of data in it. Some tables have upward of half a million rows.

The Django Admin works fine when listing the objects in a table (ei: /admin/users) and it's quite snappy because it only displays 100 objects at a time (the list view is paginated)

But then when I inspect one of the objects (ei: /admin/users/1) then a very lengthy query starts to join and list all items in tables that have a relationship with this object. This happens because some of the admin widgets are not paginated and would want to display all .5 million objects in that single widget. The query is usually too long and the request times out. Usually it times out even earlier at around 100k rows. (1 foreignKey relationship to a 100k table takes 512 seconds, verified using Django-debug-toolbar)

It's quite insane for widget to display all of that info just as much as it's crazy to expect the user to browse (by means of a scrollbar) 100k-1M rows.

The current widgets used in the Admin are "good defaults" for small tables, but *not* good defaults for the general case.

I think that a lot of pain could be avoided for a lot of people if the default widgets used in the Admin were paginated as well just like the list views of the Admin is.

Change History (6)

comment:1 Changed 2 years ago by gabreyla@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 2 years ago by timo

Have you tried raw_id_fields?

comment:3 Changed 2 years ago by gabreyla@…

I haven't tried that yet actually. It's hardly ideal though. (only the IDs are displayed and you can't browse to select other options)
Do you think it would be possible to replace the current list widget with the corresponding admin list view for that object? So that for example if you specify that the OrgAdmin has a search box on the field 'name', then the 'detailed view Admin' for User will use the Admin list view of Orgs with the search box as the widget to select the Org? (which also means that by default is paginated) (Admin-ception style)

Thank you for replying and sharing!

comment:4 Changed 2 years ago by timo

  • Resolution set to worksforme
  • Status changed from new to closed

Actually, you can browse to select other options (click the magnifying glass icon) and those results are paginated with a search box as you describe. Please give it a try!

comment:5 Changed 2 years ago by gabreyla@…

Thank you timo, your suggestion works quite well for IDs. Do you know if I can use some other unique column instead of the primary key?

I agree this ticket is now closed

comment:6 Changed 2 years ago by timo

No, I don't think so.

If you have further questions, see Getting Help for some better places to ask questions. We try to avoid using this ticket tracker as a support channel, thanks!

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