old_contents: """Views for Zinnia Hashids"""
  from django.shortcuts import get_object_or_404
  from django.views.generic.base import RedirectView
  
  from zinnia.models.entry import Entry
  
  from zinnia_hashids.factory import hashids
  
  
  class EntryHashids(RedirectView):
      """
      View for handling the hashids of an Entry,
      simply do a redirection.
      """
      permanent = True
  
      def get_redirect_url(self, **kwargs):
          """
          Get entry corresponding to 'pk' encoded by hashids
          in the 'token' variable and return the get_absolute_url
          of the entry.
          """
          unhashed_pk = hashids.decode(kwargs['token'])[0]
          entry = get_object_or_404(Entry.published, pk=unhashed_pk)
          return entry.get_absolute_url()
  
new_contents: """Views for Zinnia Hashids"""
  from django.http import Http404
  from django.shortcuts import get_object_or_404
  from django.views.generic.base import RedirectView
  
  from zinnia.models.entry import Entry
  
  from zinnia_hashids.factory import hashids
  
  
  class EntryHashids(RedirectView):
      """
      View for handling the hashids of an Entry,
      simply do a redirection.
      """
      permanent = True
  
      def get_redirect_url(self, **kwargs):
          """
          Get entry corresponding to 'pk' encoded by hashids
          in the 'token' variable and return the get_absolute_url
          of the entry.
          """
          try:
              unhashed_pk = hashids.decode(kwargs['token'])[0]
          except IndexError:
              raise Http404('Invalid hash')
          entry = get_object_or_404(Entry.published, pk=unhashed_pk)
          return entry.get_absolute_url()
  
subject: Handle invalid hash