Ticket #1425: django_1425.diff

File django_1425.diff, 1.4 KB (added by Christopher Lenz <cmlenz@…>, 9 years ago)

Patch that updates the shortcut view for the new model API

  • django/views/defaults.py

     
    88    "Redirect to an object's page based on a content-type ID and an object ID."
    99    # Look up the object, making sure it's got a get_absolute_url() function.
    1010    try:
    11         content_type = ContentType.objects.get_object(pk=content_type_id)
     11        content_type = ContentType.objects.get(pk=content_type_id)
    1212        obj = content_type.get_object_for_this_type(pk=object_id)
    1313    except ObjectDoesNotExist:
    1414        raise http.Http404, "Content type %s object %s doesn't exist" % (content_type_id, object_id)
     
    2727    object_domain = None
    2828
    2929    # Next, look for an many-to-many relationship to sites
    30     if hasattr(obj, 'get_site_list'):
    31         site_list = obj.get_site_list()
    32         if site_list:
    33             object_domain = site_list[0].domain
     30    if hasattr(obj, 'sites'):
     31        try:
     32            object_domain = obj.sites.all()[0].domain
     33        except Site.DoesNotExist:
     34            pass
    3435
    3536    # Next, look for a many-to-one relationship to sites
    36     elif hasattr(obj, 'get_site'):
     37    elif hasattr(obj, 'site'):
    3738        try:
    38             object_domain = obj.get_site().domain
     39            object_domain = obj.site.domain
    3940        except Site.DoesNotExist:
    4041            pass
    4142
Back to Top