Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #634 -- Changed shortcut view to accept get_absolute_url()s tha…

…t return URLs starting with http. Thanks, Hugo

git-svn-id: http://code.djangoproject.com/svn/django/trunk@903 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 383704ac844323375e743b555f6a64d6daf6d14d 1 parent 0bb68cd
Adrian Holovaty authored October 17, 2005

Showing 1 changed file with 7 additions and 3 deletions. Show diff stats Hide diff stats

  1. 10  django/views/defaults.py
10  django/views/defaults.py
@@ -10,8 +10,12 @@ def shortcut(request, content_type_id, object_id):
10 10
         obj = content_type.get_object_for_this_type(pk=object_id)
11 11
     except ObjectDoesNotExist:
12 12
         raise Http404, "Content type %s object %s doesn't exist" % (content_type_id, object_id)
13  
-    if not hasattr(obj, 'get_absolute_url'):
  13
+    try:
  14
+        absurl = obj.get_absolute_url()
  15
+    except AttributeError:
14 16
         raise Http404, "%s objects don't have get_absolute_url() methods" % content_type.name
  17
+    if absurl.startswith('http://'):
  18
+        return httpwrappers.HttpResponseRedirect(absurl)
15 19
     object_domain = None
16 20
     if hasattr(obj, 'get_site_list'):
17 21
         site_list = obj.get_site_list()
@@ -27,8 +31,8 @@ def shortcut(request, content_type_id, object_id):
27 31
     except sites.SiteDoesNotExist:
28 32
         pass
29 33
     if not object_domain:
30  
-        return httpwrappers.HttpResponseRedirect(obj.get_absolute_url())
31  
-    return httpwrappers.HttpResponseRedirect('http://%s%s' % (object_domain, obj.get_absolute_url()))
  34
+        return httpwrappers.HttpResponseRedirect(absurl)
  35
+    return httpwrappers.HttpResponseRedirect('http://%s%s' % (object_domain, absurl))
32 36
 
33 37
 def page_not_found(request):
34 38
     """

0 notes on commit 383704a

Please sign in to comment.
Something went wrong with that request. Please try again.