def test_shortcut_view(self):
    '\n        Check that the shortcut view (used for the admin "view on site"\n        functionality) returns a complete URL regardless of whether the sites\n        framework is installed\n        '
    request = HttpRequest()
    request.META = {'SERVER_NAME': 'Example.com', 'SERVER_PORT': '80'}
    from django.contrib.auth.models import User
    user_ct = ContentType.objects.get_for_model(User)
    obj = User.objects.create(username='john')
    if Site._meta.installed:
        current_site = Site.objects.get_current()
        response = shortcut(request, user_ct.id, obj.id)
        self.assertEqual(('http://%s/users/john/' % current_site.domain), response._headers.get('location')[1])
    Site._meta.installed = False
    response = shortcut(request, user_ct.id, obj.id)
    self.assertEqual('http://Example.com/users/john/', response._headers.get('location')[1])
Check that the shortcut view (used for the admin "view on site"
functionality) returns a complete URL regardless of whether the sites
framework is installed
def test_shortcut_view(self):
    '\n        Check that the shortcut view (used for the admin "view on site"\n        functionality) returns a complete URL regardless of whether the sites\n        framework is installed\n        '
    request = HttpRequest()
    request.META = {'SERVER_NAME': 'Example.com', 'SERVER_PORT': '80'}
    from django.contrib.auth.models import User
    user_ct = ContentType.objects.get_for_model(User)
    obj = User.objects.create(username='john')
    if Site._meta.installed:
        current_site = Site.objects.get_current()
        response = shortcut(request, user_ct.id, obj.id)
        self.assertEqual(('http://%s/users/john/' % current_site.domain), response._headers.get('location')[1])
    Site._meta.installed = False
    response = shortcut(request, user_ct.id, obj.id)
    self.assertEqual('http://Example.com/users/john/', response._headers.get('location')[1])