              site=self.site, old_path='/initial', new_path='/new_target')
          response = self.client.get('/initial')
          self.assertRedirects(response,
              '/new_target', status_code=301, target_status_code=404)
          # Works also with trailing slash
          response = self.client.get('/initial/')
          self.assertRedirects(response,
              '/new_target', status_code=301, target_status_code=404)
  
      def test_response_gone(self):
          """When the redirect target is '', return a 410"""
 
</s> remove             '/new_target', status_code=301, target_status_code=404)
 </s> add             '/new_target/', status_code=301, target_status_code=404)

    @override_settings(APPEND_SLASH=True)
    def test_redirect_with_append_slash_and_query_string(self):
        Redirect.objects.create(
            site=self.site, old_path='/initial/?foo', new_path='/new_target/')
        response = self.client.get('/initial?foo')
        self.assertRedirects(response,
            '/new_target/', status_code=301, target_status_code=404) </s> remove     def test_redirect_middleware(self):
        r1 = Redirect.objects.create(
 </s> add     def test_redirect(self):
        Redirect.objects.create( </s> remove         r1 = Redirect.objects.create(
 </s> add         Redirect.objects.create( </s> remove             r = None
        if r is None and settings.APPEND_SLASH:
            # Try removing the trailing slash.
 </s> add             pass
        if settings.APPEND_SLASH and not request.path.endswith('/'):
            # Try appending a trailing slash.
            path_len = len(request.path)
            full_path = full_path[:path_len] + '/' + full_path[path_len:] </s> remove                 r = Redirect.objects.get(site__id__exact=current_site.id,
                    old_path=path[:path.rfind('/')]+path[path.rfind('/')+1:])
 </s> add                 r = Redirect.objects.get(site=current_site, old_path=full_path)
    @override_settings(APPEND_SLASH=True)
    def test_redirect_with_append_slash(self):
        Redirect.objects.create(
            site=self.site, old_path='/initial/', new_path='/new_target/')
        response = self.client.get('/initial')
              site=self.site, old_path='/initial', new_path='/new_target')
          response = self.client.get('/initial')
          self.assertRedirects(response,
              '/new_target', status_code=301, target_status_code=404)
    @override_settings(APPEND_SLASH=True)
    def test_redirect_with_append_slash(self):
        Redirect.objects.create(
            site=self.site, old_path='/initial/', new_path='/new_target/')
        response = self.client.get('/initial')
    @override_settings(APPEND_SLASH=True)
    def test_redirect_with_append_slash(self):
        Redirect.objects.create(
            site=self.site, old_path='/initial/', new_path='/new_target/')
        response = self.client.get('/initial')
          self.assertRedirects(response,
              '/new_target', status_code=301, target_status_code=404)
  
      def test_response_gone(self):
          """When the redirect target is '', return a 410"""
keep keep keep keep replace replace keep keep keep keep keep
 Fixed #19772 -- Handled APPEND_SLASH correctly in the redirects app. 
django/contrib/redirects/tests.py