{"action":"created","issue":{"url":"https://api.github.com/repos/coleifer/peewee/issues/660","labels_url":"https://api.github.com/repos/coleifer/peewee/issues/660/labels{/name}","comments_url":"https://api.github.com/repos/coleifer/peewee/issues/660/comments","events_url":"https://api.github.com/repos/coleifer/peewee/issues/660/events","html_url":"https://github.com/coleifer/peewee/issues/660","id":95860329,"number":660,"title":"Simple question on multiple Model instances from single Join query","user":{"login":"jessepeterson","id":694298,"avatar_url":"https://avatars.githubusercontent.com/u/694298?v=3","gravatar_id":"","url":"https://api.github.com/users/jessepeterson","html_url":"https://github.com/jessepeterson","followers_url":"https://api.github.com/users/jessepeterson/followers","following_url":"https://api.github.com/users/jessepeterson/following{/other_user}","gists_url":"https://api.github.com/users/jessepeterson/gists{/gist_id}","starred_url":"https://api.github.com/users/jessepeterson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessepeterson/subscriptions","organizations_url":"https://api.github.com/users/jessepeterson/orgs","repos_url":"https://api.github.com/users/jessepeterson/repos","events_url":"https://api.github.com/users/jessepeterson/events{/privacy}","received_events_url":"https://api.github.com/users/jessepeterson/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-18T21:15:02Z","updated_at":"2015-07-20T16:29:37Z","closed_at":"2015-07-20T16:29:37Z","body":"First: thanks for Peewee: it's great! Sorry to litter the bug tracker with a simple question, but I'm not able to figure out how to get multiple model instances from a single joined row. For example:\r\n\r\n```python\r\nq = Student.select(Student, Teacher).join(StudentTeacher).join(Teacher).where(Student.name == 'Bob')\r\n\r\nfor row in q:\r\n    print row # is only a Student instance, where is Teacher?\r\n```\r\n\r\nWhen I iterate over `q` I only get a Student instance. How do I get the associated Teacher model instance out of a simple join query like above? When I turn on query logging it's clearly querying for the relevant fields.\r\n\r\nI could use `.dict()` to get the raw values and rebuild each model instance separately I suppose but that seems overly laborious."},"comment":{"url":"https://api.github.com/repos/coleifer/peewee/issues/comments/122940999","html_url":"https://github.com/coleifer/peewee/issues/660#issuecomment-122940999","issue_url":"https://api.github.com/repos/coleifer/peewee/issues/660","id":122940999,"user":{"login":"coleifer","id":119974,"avatar_url":"https://avatars.githubusercontent.com/u/119974?v=3","gravatar_id":"","url":"https://api.github.com/users/coleifer","html_url":"https://github.com/coleifer","followers_url":"https://api.github.com/users/coleifer/followers","following_url":"https://api.github.com/users/coleifer/following{/other_user}","gists_url":"https://api.github.com/users/coleifer/gists{/gist_id}","starred_url":"https://api.github.com/users/coleifer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coleifer/subscriptions","organizations_url":"https://api.github.com/users/coleifer/orgs","repos_url":"https://api.github.com/users/coleifer/repos","events_url":"https://api.github.com/users/coleifer/events{/privacy}","received_events_url":"https://api.github.com/users/coleifer/received_events","type":"User","site_admin":false},"created_at":"2015-07-20T16:29:37Z","updated_at":"2015-07-20T16:29:37Z","body":"You need to also select the junction table:\r\n\r\n```python\r\nq = Student.select(Student, StudentTeacher, Teacher).join(StudentTeacher).join(Teacher).where(Student.name == 'Bob')\r\n```\r\n\r\nThen you can access it via:\r\n\r\n```python\r\nrow.studentteacher.teacher\r\n```"}}