Ticket #1425: django_1425.diff
File django_1425.diff, 1.4 KB (added by , 19 years ago) |
---|
-
django/views/defaults.py
8 8 "Redirect to an object's page based on a content-type ID and an object ID." 9 9 # Look up the object, making sure it's got a get_absolute_url() function. 10 10 try: 11 content_type = ContentType.objects.get _object(pk=content_type_id)11 content_type = ContentType.objects.get(pk=content_type_id) 12 12 obj = content_type.get_object_for_this_type(pk=object_id) 13 13 except ObjectDoesNotExist: 14 14 raise http.Http404, "Content type %s object %s doesn't exist" % (content_type_id, object_id) … … 27 27 object_domain = None 28 28 29 29 # 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 34 35 35 36 # Next, look for a many-to-one relationship to sites 36 elif hasattr(obj, ' get_site'):37 elif hasattr(obj, 'site'): 37 38 try: 38 object_domain = obj. get_site().domain39 object_domain = obj.site.domain 39 40 except Site.DoesNotExist: 40 41 pass 41 42