提交 670d8cb9 编写于 作者: P Pzqqt

utils: common: SortableModelChoiceField: Simpler

上级 9186e6e4
......@@ -43,9 +43,7 @@ class SortableModelChoiceField(forms.ModelChoiceField):
yield from choices
return
if self.field.empty_label is not None:
choices = list(choices)
yield choices[0]
choices = choices[1:]
yield next(choices)
yield from sorted(choices, key=lambda choice: sort_key(choice[0].instance))
iterator = _ModelChoiceIterator
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册