I've been trying (and failing) to generate a query that omits results from a model without having to make a second database.
pmrs.models.LootTable
class LootTable(models.Model):
boss = models.CharField(max_length=255)
itemid = models.IntegerField()
itemname = models.CharField(max_length=255)
wfflag = models.BooleanField(help_text="Set true if warforged")
That's the model layout. What I'm trying to get is a list of everything in the boss field, but then omit the duplicates.
I've tried various different ways, .value_list, .values, order_by.().distinct etc. but nothing seems to work.
Using the following
bosses = LootTable.objects.values('boss').distinct()
Returns
[{'boss': u'Thok the Bloodthirsty'}, {'boss': u'Ordos'}, {'boss': u'Paragons of the Klaxxi'}, {'boss': u'Ordos'}, {'boss': u'Spoils of Pandaria'}, {'boss': u'Spoils of Pandaria'}, {'boss': u'Galakras'}, {'boss': u'General Nazgrim'}, {'boss': u'Ordos'}, {'boss': u'Spoils of Pandaria'}, {'boss': u'Siegecrafter Blackfuse'}, '...(remaining elements truncated)...']
As you can see from the results it's returning duplicates.