I am unable to read the column of another table which is joined. It throws AttributeError
class Component(Model):
id = IntegerField(primary_key=True)
title = CharField()
class GroupComponentMap(Model):
group = ForeignKeyField(Component, related_name='group_fk')
service = ForeignKeyField(Component, related_name='service_fk')
Now the query is
comp = (Component
.select(Component, GroupComponent.group.alias('group_id'))
.join(GroupComponent, on=(Component.id == GroupComponent.group))
)
for row in comp:
print row.group_id
Now I get an error AttributeError: 'Component' object has no attribute 'group_id'