在Django的实际项目开发中,我们会使用到 不等于的情况,比如我想查询id!=3的结果,下面直接给出代码实例。
方法一
from django.db.models import Q Model.objects.filter(~Q(id = 3))
方法二
Model.objects.filter(xxxxxxxx).exclude(id=3)
');mask-image:url('data:image/svg+xml;utf8,');mask-mode:alpha;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-position:center;mask-position:center;border-radius:0}}.wp-block-image :where(.has-border-color){border-style:solid}.wp-block-image :where([style*=border-top-color]){border-top-style:solid}.wp-block-image :where([style*=border-right-color]){border-right-style:solid}.wp-block-image :where([style*=border-bottom-color]){border-bottom-style:solid}.wp-block-image :where([style*=border-left-color]){border-left-style:solid}.wp-block-image :where([style*=border-width]){border-style:solid}.wp-block-image :where([style*=border-top-width]){border-top-style:solid}.wp-block-image :where([style*=border-right-width]){border-right-style:solid}.wp-block-image :where([style*=border-bottom-width]){border-bottom-style:solid}.wp-block-image :where([style*=border-left-width]){border-left-style:solid}.wp-block-image figure{margin:0}/*]]>*/
在Django的实际项目开发中,我们会使用到 不等于的情况,比如我想查询id!=3的结果,下面直接给出代码实例。
from django.db.models import Q Model.objects.filter(~Q(id = 3))
Model.objects.filter(xxxxxxxx).exclude(id=3)
作者:
标签