当前位置: 动力学知识库 > 问答 > 编程问答 >

python - Sort and show objects with True in BooleanField first

问题描述:

There is a class in my models, and it has BooleanField.

I

want to make a sorting in which objects with BooleanField=True is shown first.

Is there a something for doing this in Django? I was searching through documentation but had no success.

网友答案:

Try:

Foo.objects.all().order_by('-field')

Like for any other field type.

分享给朋友:
您可能感兴趣的文章:
随机阅读: