B
B
Bjornie2017-10-03 22:17:58
Django
Bjornie, 2017-10-03 22:17:58

How to solve the problem of long lists (select->option) in Django?

The question concerns the admin part in the fields with the tag, the list of options () of which in some cases can be very long. First of all, this complicates the search for the desired option, and secondly, the list can get so large that the page freezes (I had this) until everything is rendered.
Please let me know if you have had the same problem, how did you solve it? Are there ready-made tools that connect something like a search filter to the floor, in which you can enter part of a string and similar options will appear (for example).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2017-10-03
@Bjornie

For lists that are so long that it takes a long time to search in them, there are filter_horizonal and filter_vertical . And for such large ones that the page gets stuck, the simplest is raw_id_fields . But not the most convenient. You can solve this problem, for example, using django-select2 . It has a widget that adds autocomplete to raw_id_field.

R
Roman Kitaev, 2017-10-03
@deliro

There is select2, which has the ability to receive data ajax'om.
But no one forbids writing your own widget for this with autoloading on scroll and autocompletion, for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question