Задать вопрос

Тел: +7 965 3737 888

472

Просмотров

0

Ответов

FeaturedModelChoiceField

<p>Here is a way to get a drop down list from a queryset, with a list of "featured" items appearing at the top (from another queryset). This can be used for long select boxes which have a subset of commonly used values. The empty label is used as a separator and values can appear in both the featured set and the full set (it's more usable if they are in both).</p>
<p>For example a country drop down list with 5 featured countries might look like this:</p>
Andorra
Australia
Kazakhstan
Singapore
Turkey
------------
Afghanistan
Albania
Algeria
American Samoa
Andorra
Angola
(hundreds more)

<p>To use this, define your form field like this:</p>
country = FeaturedModelChoiceField(queryset=Country.objects.all(),
                featured_queryset=Country.objects.featured())

Вопрос полезен? Да0/Нет0
file_4970.py(2.9Кб)
None