X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/5a45551fd535081084355dba85642ada72b71750..ace621afe8c9c2e835001bac819302cbdeb5e2df:/models/base.py diff --git a/models/base.py b/models/base.py index 23cccb6..05074c3 100644 --- a/models/base.py +++ b/models/base.py @@ -175,11 +175,15 @@ class QuerySetMapper(object, DictMixin): def __getitem__(self, key): try: - return self.queryset.get(key__exact=key).value + value = self.queryset.get(key__exact=key).value except ObjectDoesNotExist: if self.passthrough is not None: return self.passthrough.__getitem__(key) raise KeyError + else: + if value is not None: + return value.value + return value def keys(self): keys = set(self.queryset.values_list('key', flat=True).distinct()) @@ -336,11 +340,5 @@ class TreeEntity(Entity, TreeModel): return QuerySetMapper(self.attribute_set, passthrough=self.parent.attributes) return super(TreeEntity, self).attributes - @property - def relationships(self): - if self.parent: - return QuerySetMapper(self.relationship_set, passthrough=self.parent.relationships) - return super(TreeEntity, self).relationships - class Meta: abstract = True \ No newline at end of file