最好的方法是什么?
Object.objects.filter(country_send=country).exclude(status__exact='').order_by('-id')
Object.objects.filter(country_send=country).exclude(status__exact='deleted').order_by('-id')
我试图排除没有状态和状态为“已删除”的对象。我能按一个顺序做吗?如果不是,最好的方法是什么?
我是刚来的。
谢谢
最佳答案
你可以尝试使用“列表”。在状态列表中,您可以添加所需的所有单词。
status = ['deleted', '']
Object.objects.filter(country_send=country).exclude(status__in=status).order_by('-id')
有关列表的详细信息:http://www.sthurlow.com/python/lesson06/