'Django REST framework @api_view() - Get all unique elements within multiple lists

@api_view(["GET"])
def retrieve_elements(request):
    listOfLists = Event.objects.all().values(‘key’).distinct()

If the value of 'key’ is a list, then listOfLists will consist of all the unique lists whose key is ‘key’. However, although the returned lists may be unique from one another, any two lists could still share common elements.

Is there some variation of Event.objects.all().values(‘key’).distinct() that will directly get all of the unique elements from the lists?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source