Ticket #7135: databrowse-fix-for-inheritance.diff
File databrowse-fix-for-inheritance.diff, 1.5 KB (added by , 17 years ago) |
---|
-
django/contrib/databrowse/datastructures.py
10 10 from django.utils.encoding import smart_unicode, smart_str, iri_to_uri 11 11 from django.utils.safestring import mark_safe 12 12 from django.db.models.query import QuerySet 13 13 from django.core.exceptions import ObjectDoesNotExist 14 14 15 EMPTY_VALUE = '(None)' 15 16 DISPLAY_SIZE = 100 16 17 … … 125 126 if rel_object.model not in self.model.model_list: 126 127 continue # Skip models that aren't in the model_list 127 128 em = EasyModel(self.model.site, rel_object.model) 129 try: 130 rel_accessor = getattr(self.instance, rel_object.get_accessor_name()) 131 except ObjectDoesNotExist: 132 continue 133 if rel_object.field.rel.multiple: 134 object_list = [EasyInstance(em, i) for i in rel_accessor.all()] 135 else: # for one-to-one fields 136 object_list = [EasyInstance(em, rel_accessor)] 128 137 yield { 129 138 'model': em, 130 139 'related_field': rel_object.field.verbose_name, 131 'object_list': [EasyInstance(em, i) for i in getattr(self.instance, rel_object.get_accessor_name()).all()],140 'object_list': object_list 132 141 } 133 142 134 143 class EasyInstanceField(object):