Code

Opened 8 months ago

Closed 7 months ago

Last modified 7 months 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

Description

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.

Attachments (0)

Change History (6)

comment:1 Changed 8 months ago by gabreyla@…

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

comment:2 Changed 8 months ago by timo

Have you tried raw_id_fields?

comment:3 Changed 8 months 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 7 months 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 7 months 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 7 months 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!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.