Hello all,<div><br></div><div>Can anyone help me see what I&#39;m doing wrong here?<br><div><br></div><div>SQL</div><div><br></div><div><div>CREATE TABLE IF NOT EXISTS `author` (</div><div>  `id` int(8) NOT NULL auto_increment,</div>
<div>  `first_name` varchar(32) NOT NULL,</div><div>  `last_name` varchar(32) NOT NULL,</div><div>  PRIMARY KEY  (`id`)</div><div>) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;</div><div><br></div><div><br></div>
<div>CREATE TABLE IF NOT EXISTS `book` (</div><div>  `id` int(8) NOT NULL auto_increment,</div><div>  `title` varchar(64) NOT NULL,</div><div>  `author_id` int(8) NOT NULL,</div><div>  PRIMARY KEY  (`id`)</div><div>) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;</div>
<div><br></div><div><br></div><div><div>PYTHON</div><div><br></div><div>database = create_database(&quot;mysql://uname:password@localhost:3306/DB&quot;)</div><div>store = Store(database)</div><div><br></div><div>class Book(Storm):</div>
<div>    __storm_table__ = &quot;book&quot;</div><div>    id=Int(primary=True)</div><div>    title = Unicode()</div><div>    author_id=Int()</div><div>    author = Reference(author_id,&quot;Author.id&quot;)</div><div>    def __init__(self, title):</div>
<div>        self.title = title</div><div>  </div><div>class Author(Storm):</div><div>    __storm_table__=&quot;author&quot;</div><div>    id=Int(primary=True)</div><div>    first_name=Unicode()</div><div>    last_name=Unicode()</div>
<div>    books= ReferenceSet(id,&quot;Book.id&quot;)</div><div>    def __init__(self, first_name, last_name):</div><div>        self.first_name = first_name</div><div>        self.last_name = last_name</div><div>        </div>
<div>dog=store.add(Book(u&quot;Dog Called Demolition&quot;))</div><div>rankin=store.add(Author(u&quot;Robert&quot;, u&quot;Rankin&quot;))</div><div>store.flush()</div><div>print &quot;rankin id is %i&quot; % (<a href="http://rankin.id">rankin.id</a>)</div>
<div>print &quot;dog id is %i&quot; % (<a href="http://dog.id">dog.id</a>)</div><div>rankin.books.add(dog)</div><div>print &quot;rankin book 1 = %s&quot; %(rankin.books.one().title)</div><div>print &quot;dog author name = %s&quot; % (dog.author.first_name)</div>
<div><br></div><div>The error given is:</div><div><br></div><div><div>Traceback (most recent call last):</div><div>  File &quot;models.py&quot;, line 33, in &lt;module&gt;</div><div>    print &quot;dog author name = %s&quot; % (dog.author.first_name)</div>
<div>AttributeError: &#39;NoneType&#39; object has no attribute &#39;first_name&#39;</div><div><br></div><div>I thought storm should automatically assign the author_id to the book object when the book is added to the Author-object &quot;books&quot; set.</div>
<div><br></div><div>Cheers,</div><div>Pete.</div></div></div></div></div>