def to_dict(self, fields=None):
        if fields:
            model_fields, ed_fields = split_model_fields(self, fields)
            extra_data = self.extra_data
            ed_fields = filter(lambda f: f in extra_data, ed_fields)

            result = {
                field: getattr(self, field) for field in model_fields
            }
            result['extra_data'] = {
                field: extra_data[field] for field in ed_fields
            }

            # always return id's and canonical_building id's
            result['id'] = result['pk'] = self.pk
            result['canonical_building'] = (
                self.canonical_building and self.canonical_building.pk
            )

            # should probably also return children, parents, and coparent
            result['children'] = map(lambda c: c.id, self.children.all())
            result['parents'] = map(lambda p: p.id, self.parents.all())
            result['co_parent'] = (self.co_parent and self.co_parent.pk)
            result['coparent'] = (self.co_parent and {
                field: self.co_parent.pk for field in ['pk', 'id']
            })

            return result

        d = obj_to_dict(self)
        d['parents'] = list(self.parents.values_list('id', flat=True))
        d['co_parent'] = self.co_parent.pk if self.co_parent else None
        return d
Returns a dict version of this building, either with all fields
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/models.py/BuildingSnapshot.to_dict