Ticket #17200: django.contrib.contenttypes.views.diff

File django.contrib.contenttypes.views.diff, 1.4 KB (added by David Chandek-Stark, 13 years ago)
  • django/contrib/contenttypes/views.py

     
    11from django import http
     2from django.contrib.admin.util import unquote
    23from django.contrib.contenttypes.models import ContentType
    34from django.contrib.sites.models import Site, get_current_site
    45from django.core.exceptions import ObjectDoesNotExist
     
    67def shortcut(request, content_type_id, object_id):
    78    "Redirect to an object's page based on a content-type ID and an object ID."
    89    # Look up the object, making sure it's got a get_absolute_url() function.
     10    obj_id = unquote(object_id)
    911    try:
    1012        content_type = ContentType.objects.get(pk=content_type_id)
    1113        if not content_type.model_class():
    1214            raise http.Http404("Content type %s object has no associated model" % content_type_id)
    13         obj = content_type.get_object_for_this_type(pk=object_id)
     15        obj = content_type.get_object_for_this_type(pk=obj_id)
    1416    except (ObjectDoesNotExist, ValueError):
    15         raise http.Http404("Content type %s object %s doesn't exist" % (content_type_id, object_id))
     17        raise http.Http404("Content type %s object %s doesn't exist" % (content_type_id, obj_id))
    1618    try:
    1719        absurl = obj.get_absolute_url()
    1820    except AttributeError:
Back to Top