Ticket #17200: django.contrib.contenttypes.views.diff
File django.contrib.contenttypes.views.diff, 1.4 KB (added by , 13 years ago) |
---|
-
django/contrib/contenttypes/views.py
1 1 from django import http 2 from django.contrib.admin.util import unquote 2 3 from django.contrib.contenttypes.models import ContentType 3 4 from django.contrib.sites.models import Site, get_current_site 4 5 from django.core.exceptions import ObjectDoesNotExist … … 6 7 def shortcut(request, content_type_id, object_id): 7 8 "Redirect to an object's page based on a content-type ID and an object ID." 8 9 # Look up the object, making sure it's got a get_absolute_url() function. 10 obj_id = unquote(object_id) 9 11 try: 10 12 content_type = ContentType.objects.get(pk=content_type_id) 11 13 if not content_type.model_class(): 12 14 raise http.Http404("Content type %s object has no associated model" % content_type_id) 13 obj = content_type.get_object_for_this_type(pk=obj ect_id)15 obj = content_type.get_object_for_this_type(pk=obj_id) 14 16 except (ObjectDoesNotExist, ValueError): 15 raise http.Http404("Content type %s object %s doesn't exist" % (content_type_id, obj ect_id))17 raise http.Http404("Content type %s object %s doesn't exist" % (content_type_id, obj_id)) 16 18 try: 17 19 absurl = obj.get_absolute_url() 18 20 except AttributeError: