Issue
how to remove duplicates after merging two different models like this
import itertools
events_list = list(itertools.chain(events_list, speakers_list))
I am getting duplicate values in the Django REST serializer
Solution
You can use union()
; here is doc about union()
qs1.union(qs2)
# no duplicates
By default, union()
only gives you distinct values. If you want to allow duplicates, you use
qs1.union(qs2, all=True)
# allow duplicates
Answered By - ha-neul
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.