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

Тел: +7 965 3737 888

508

Просмотров

0

Ответов

sort_by_id_sequence

<p>I needed to sort a set of objects (a QuerySet for example) by an externally provided list of IDs - for example:</p>
&gt;&gt;&gt; writers = Writer.objects.all()
&gt;&gt;&gt; sort_by_id_sequence(writers, [3, 1, 2])
[&lt;Writer id: 3&gt;, &lt;Writer id: 1&gt;, &lt;Writer id: 2&gt;]

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