1👍
✅
perhaps not the most efficient solution (my gut tells me something with sets could be marginally better, if sets have some kind of distinct lambda function or something…), but would easily work to do:
results = Calls.objects.order_by("followupdate")
newresults = []
seen_altid = []
for result in results:
if result.altid not in seen_altids:
seen_altids.append(result.altid)
newresults.append(result)
btw, though, sounds like you want to order by -followupdate
if you use this solution so that you’ll get 3,1 and not 1,1
EDIT: jk, http://www.peterbe.com/plog/uniqifiers-benchmark seems to back me up on this solution. With the slight modification of seen being a dict, presumably for O(1) lookups. Which is cool if you need it (though unless your result set size is enormous it’s really probably unnecessary)
Source:stackexchange.com