'Only admin users should be able to use the admin shortcut view.'

def test_shortcut_view_only_available_to_staff(self):

    model_ctype = ContentType.objects.get_for_model(ModelWithStringPrimaryKey)
    obj = ModelWithStringPrimaryKey.objects.create(string_pk='foo')
    shortcut_url = reverse('admin:view_on_site', args=(model_ctype.pk, obj.pk))
    response = self.client.get(shortcut_url, follow=True)
    self.assertTemplateUsed(response, 'admin/login.html')
    self.client.force_login(self.superuser)
    response = self.client.get(shortcut_url, follow=False)
    self.assertEqual(response.status_code, 302)
    self.assertRegex(response.url, 'http://(testserver|example.com)/dummy/foo/')
