Display users assigned to a ticket model without showing duplicates

So I’m creating a bug tracker in django, I want to display all the users that are assigned to a ticket and currently I have a table that displays these users. However, the assigned users are duplicated. How do I show all the assigned users without showing duplicates.

here is my template that shows the assigned users

<tbody>
  {% for ticket in page_obj %}
  <tbody>
    {% for user in ticket.assignee.all %}
      <tr>
      <td><a href="">{{user.username}}</a></td>
      <td>{{user.email}}</td>
      <td></td>
      <td>{{user.get_account_type_display}}</td>
      
      </tr>
    {% endfor %}
  </tbody>
{% endfor %}
</tbody>

view function

class ProjectView(View):
    def get(self, request, pk):
        projects = Project.objects.get(id=pk)
        search_query = request.GET.get('search')
        tickets = Ticket.objects.filter(project=projects)
        
        # Search functionality
        if search_query:
            tickets = tickets.filter(
                Q(assignee__username__icontains=search_query) |
                Q(category__name__icontains=search_query) |
                Q(name__icontains=search_query) |
                Q(status__iexact=search_query) |
                Q(priority__icontains=search_query) |
                Q(type__icontains=search_query)
            )
            assignees = assignees.filter(username__icontains=search_query)

        ticket_assignees = {}
        
        for ticket in tickets:
            # Get the assignees for the ticket and remove duplicates
            ticket_assignees[ticket] = ticket.assignee.all().distinct()
            # Store the assignees for this ticket in the dictionary
            ticket_assignees[ticket] = assignees
            
            
        # Paginate the ticket table
        paginator = Paginator(tickets, 5)
        page_number = request.GET.get('page')
        page_obj = paginator.get_page(page_number)
        
        # Paginate the assignees table
        assignees_paginator = Paginator(assignees, 5)
        assignees_page_number = request.GET.get('assignees_page')
        assignees_page_obj = assignees_paginator.get_page(assignees_page_number)
        
            

        context = {
            'projects': projects, 
            'tickets': tickets,
            'page_obj': page_obj,
            'ticket_assignees': ticket_assignees,
            'search_query': search_query
        }

        return render(request, 'projects/project.html', context)

    def post(self, request, pk):
        # Handle POST requests
        return redirect('project', pk=pk)

ticket model

class Ticket(models.Model):
    assignee = models.ManyToManyField(CustomUser, related_name='assignee', blank=True)

If you just want to display users (and not tickets) I think the easiest way is that you should query users filtering by those who have tickets:

users = User.objects.filter(…)