1👍
✅
You can call .distinct()
on the QuerySet
you obtain with .values_list(…)
[Django-doc], so something like:
clues = Clue.objects.filter(
clue_text=clue.clue_text
).values_list('clue_text', flat=True).distinct()
But this looks more like a modeling problem: if you have a lot of duplicated data, that often means you should construct a new model that stores that data only once, and then reference that model with a relation (like a ForeignKey
, OneToOneField
or ManyToManyField
).
Source:stackexchange.com