我试图找出两个查询集之间的差异,对我来说重要的是这个差异的答案是一个查询集。因此,自然的解决方案是使用 Django 查询集的差异方法。但是,当尝试这样做时,我收到以下错误:
NotSupportedError: difference is not supported on this database backend.
这是我想做的:
In [4]: type(small_qs)
Out[4]: django.db.models.query.QuerySet
In [5]: type(bigger_qs)
Out[5]: django.db.models.query.QuerySet
In [6]: bigger_qs.difference(small_qs)
Run Code Online (Sandbox Code Playgroud)
重要提示:两个查询集来自同一模型。
其他有用的信息:
这里是完整的输出:
Out[6]: ----------------------------------------------------------------
NotSupportedError Traceback (most recent call
last)
/usr/local/lib/python3.6/site-packages/IPython/core/formatters.py in
__call__(self, obj)
700 type_pprinters=self.type_printers,
701 deferred_pprinters=self.deferred_printers)
702 printer.pretty(obj)
703 printer.flush()
704 return stream.getvalue()
/usr/local/lib/python3.6/site-packages/IPython/lib/pretty.py in
pretty(self, obj)
398 if cls is not object \
399 and
callable(cls.__dict__.get('__repr__')):
400 return _repr_pprint(obj, self, cycle)
401
402 …Run Code Online (Sandbox Code Playgroud)