Search code examples
pythondjangoadmin

Exclude duplicates from django admin page


My question is the following: can you exclude objects that are duplicated from being displayed on the admin page without DB modification, and if yes, how?

Thanks for all the help in advance


Solution

  • You can overwrite queryset inside your Admin model

    def queryset(self, request):
        qs = super(MyModelAdmin, self).queryset(request)
        # update your query somehow
        return qs.distinct()