开发者

How to improve display and handling of a large number of inlines in django-admin?

开发者 https://www.devze.com 2023-01-14 06:10 出处:网络
When displaying an inline for a model, if there\'s a large number of inlines, the change page then loads slowly, and can be hard to navigate through all of them. I\'m already using an inline-collapsin

When displaying an inline for a model, if there's a large number of inlines, the change page then loads slowly, and can be hard to navigate through all of them. I'm already using an inline-collapsing trick (found on DjangoSnippets, but the search there is not working so I can't share the link here), but still isn't easy to browse since they are named alike (mostly diferentiates in numbers) and all inlines are still loaded.

I need some kind of paginator for the inlines, and also that this paginator shows at first the most interesting inlines for the current object being edited, like spec开发者_运维知识库ifying ordering for the onlines only (not the default ordering used in other areas of the app).

UPDATE: The inlines are all instances of one child related class.


if you are trying to control the number of lists per page, you can set list_per_page=50

example

class ModelAdmin(admin.modelAdmin):
  list_per_page = 50

admin.register(model, ModelAdmin)

this solves pagination

0

精彩评论

暂无评论...
验证码 换一张
取 消