-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: inline pagination #805
Comments
Are you looking for autocomplete fields in inlines for foreign keys? This is already implemented in Django. https://github.com/unfoldadmin/formula/blob/main/src/formula/admin.py#L233 |
Thank you for pointing that out. I think we considered it and it behaved differently, but from the django documentation it might work as expected. Since we currently use django-jet-reboot and evaluate django-unfold, it might be hard to test it. But for the moment this point may be obsolete. |
Anyway, I was already looking at the optimisation of inlines and there two things which we can consider:
|
Just from my point of view: for us performance is way more important than sorting, pagination, inline search etc. We had detail pages which loaded for 10 seconds. But in a perfect world, an inline would offer the same functionalities as a ListView (pagination, sorting, search, filter). But I understand it might be difficult and some thing won't be possible. Maybe prefetch_related and select_related might be the solution, at least to reduce the queries. It will still load many objects into the RAM |
I'm not sure if this performance issue is related to the Unfold or Django admin in general. I guess you would have same problems with default admin as well, right? If I can suggest you something, please install django-debug-toolbar and look at the SQL queries. I suspect that you can have n+1 problem. Of course, if you want to display extremely large dataset in inlines (for example logs assigned to current instance) then without pagination it would be hard to optimise. |
Yes, this is no bug or anything like that in unfold, the issues also exists in the Django admin and we already improved the queryset and investigated it with the django-debug-toolbar. It's just a lot of complex data in our case. |
I understand. I think, you are looking for pagination. I will change issue title to reflect that. At the moment there is no ETA for the implementation as it depends on a lot factors. |
We just checked our code and we actually found an issue with the overridden inline formset class which should limit the amount of objects an inline should display. If we remove it, then our feature request results in an inline pagination, yes - or alternatively an efficient way to limit the amount of inline objects loaded. |
Do you have any examples?
No
Is it a third party application feature request?
For example: No/Partly
In case of third party application, when it was updated last time?
For example: last week
Describe your feature request
We noticed performance issues when using many inlines, because django loads the content with the initial page request, even if we limit the objects for inlines. A solution for us was to change inlines with simple properties which link to the changelist of the respecting models. This does work but it redirects a user to another page. It would be a better UX if the user could stay on the actual detail page.
Therefore I suggest, where possible, to add options to defer loading data and instead load them afterwards / on demand with AJAX.
For example django-jet-reboot enables you to define autocomplete fields for choices which then will be loaded via AJAX on demand.
Another inline optimization would be this package (https://github.com/DmytroLitvinov/django-admin-inline-paginator-plus) which adds pagination for inlines.
It would also be a great benefit if django-unfold would offer the option to load inlines on click (by demand) and not with the initial page request.
The text was updated successfully, but these errors were encountered: