Same used tags keeps displaying. is there a way to remove the repeated tags?

I want to display the tags in a dropdown list. But the problem here is that same tags are being displayed per post. So is there any way that I can avoid this repetition? my dropdown list is as below:

<div class="dropdown">
    <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Tags
    </button>
        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                {% for post in posts %}
                    {% for tag in post.tags.all %}
                        <a class="dropdown-item" href="{% url 'post_tag' tag.slug %}">
                            {{ tag.name }}
                        </a>
                    {% endfor %}
                {% endfor %}

        </div>
</div>

views.py

def home(request, tag_slug=None):
posts = Post.objects.all()
# tag post
tag = None
if tag_slug:
    tag = get_object_or_404(Tag, slug=tag_slug)
    posts = posts.filter(tags__in=[tag])
    
return render(request, 'blog/home.html', {'posts':posts})

It would be handy if there are any JS script or anything else to avoid this repetition. Thanks!

Back to Top