from django.views.generic import ListView


class ByTagListView(ListView):

    def get_queryset(self):
        qs = super(ByTagListView, self).get_queryset()
        if 'tag' in self.kwargs:
            qs = qs.filter(tags__slug__in=[self.kwargs['tag']])
        return qs

    def get_context_data(self, **kwargs):
        context = super(ByTagListView, self).get_context_data(**kwargs)
        context['tag'] = self.kwargs.get('tag')
        return context

from django.views.generic import ListView

from taggit.models import Tag


class ByTagListView(ListView):

    def get_queryset(self):
        qs = super(ByTagListView, self).get_queryset()
        if 'tag' in self.kwargs:
            qs = qs.filter(tags__slug__in=[self.kwargs['tag']])
        return qs

    def get_context_data(self, **kwargs):
        context = super(ByTagListView, self).get_context_data(**kwargs)
        context['tag'] = Tag.objects.get(slug=self.kwargs.get('tag'))
        return context

Use tag name not slug in tag page title
Use tag name not slug in tag page title

  from django.views.generic import ListView
+ 
+ from taggit.models import Tag
  
  
  class ByTagListView(ListView):
  
      def get_queryset(self):
          qs = super(ByTagListView, self).get_queryset()
          if 'tag' in self.kwargs:
              qs = qs.filter(tags__slug__in=[self.kwargs['tag']])
          return qs
  
      def get_context_data(self, **kwargs):
          context = super(ByTagListView, self).get_context_data(**kwargs)
-         context['tag'] = self.kwargs.get('tag')
+         context['tag'] = Tag.objects.get(slug=self.kwargs.get('tag'))
          return context
  
Use tag name not slug in tag page title
## Code Before:
from django.views.generic import ListView


class ByTagListView(ListView):

    def get_queryset(self):
        qs = super(ByTagListView, self).get_queryset()
        if 'tag' in self.kwargs:
            qs = qs.filter(tags__slug__in=[self.kwargs['tag']])
        return qs

    def get_context_data(self, **kwargs):
        context = super(ByTagListView, self).get_context_data(**kwargs)
        context['tag'] = self.kwargs.get('tag')
        return context

## Instruction:
Use tag name not slug in tag page title
## Code After:
from django.views.generic import ListView

from taggit.models import Tag


class ByTagListView(ListView):

    def get_queryset(self):
        qs = super(ByTagListView, self).get_queryset()
        if 'tag' in self.kwargs:
            qs = qs.filter(tags__slug__in=[self.kwargs['tag']])
        return qs

    def get_context_data(self, **kwargs):
        context = super(ByTagListView, self).get_context_data(**kwargs)
        context['tag'] = Tag.objects.get(slug=self.kwargs.get('tag'))
        return context
