Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm racking my brain on how to form this filter query using Django's Querysets. 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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...