Ticket #6913: databrowse-fix-for-one-to-one.patch
File databrowse-fix-for-one-to-one.patch, 1.3 KB (added by , 17 years ago) |
---|
-
datastructures.py
121 121 EasyInstance's model as a ForeignKey or ManyToManyField, along with 122 122 lists of related objects. 123 123 """ 124 def get_rel_list( instance, rel_object ): 125 attr = rel_object.get_accessor_name() 126 if rel_object.field.rel.multiple: 127 return getattr(instance, attr ).all() 128 else: 129 return [ getattr( instance, attr ) ] 130 124 131 for rel_object in self.model.model._meta.get_all_related_objects() + self.model.model._meta.get_all_related_many_to_many_objects(): 125 132 if rel_object.model not in self.model.model_list: 126 133 continue # Skip models that aren't in the model_list … … 128 135 yield { 129 136 'model': em, 130 137 'related_field': rel_object.field.verbose_name, 131 'object_list': [EasyInstance(em, i) for i in get attr(self.instance, rel_object.get_accessor_name()).all()],138 'object_list': [EasyInstance(em, i) for i in get_rel_list( self.instance, rel_object ) ] 132 139 } 133 140 134 141 class EasyInstanceField(object):