I'm racking my brain on how to form this filter query using Django's Queryset
s. The following filter query returns objects containing the following fields: candidate
, informationField
, option
.
selected_options = CandidateInformationListOptionsAnswer.objects.filter(
candidate=candidate, informationField=element
)
In selected_option
, every object will have the same values for candidate
and informationField
. However, the option
fields in the objects in the QuerySet
have duplicates, when they should instead be unique.
Therefore, I want to run the equivalent of a .distinct("option")
call on selected_options
, but my DB backend is not Postgres, so I don't have the ability to pass in field names into a QuerySet.distinct()
call.
How would I structure my .filter()
queries to get a QuerySet
of objects that are distinct for a particular field with a SQLite backend?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…