Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ReferenceProperty" rel="nofollow">ReferenceProperties</a> add <a href="http://code.google.com/appengine/docs/python/datastore/queryclass.html" rel="nofollow">query-objects</a> as attributes to the referenced class. So look carefully at your mappings:</p> <pre><code>class BookAuthor(db.Model): # This adds a query-object as an attribute named 'books' to Book entities. book = db.ReferenceProperty(Book, required=True, collection_name='books') # This adds a query-object as an attribute named 'authors' to Author entities. author = db.ReferenceProperty(Author, required=True, collection_name='authors') </code></pre> <p>In your code:</p> <pre><code>b = Book(title="My Book") a = Author(name="Author of My Book") </code></pre> <p>So, <code>b</code> would have a <code>books</code> attribute, not <code>authors</code>. And, <code>a</code> would have a <code>authors</code> attribute, not <code>books</code>. </p> <p>If you change the collection names, your code should run.</p> <pre><code>class BookAuthor(db.Model): # This adds a query-object as an attribute named 'authors' to Book entities. book = db.ReferenceProperty(Book, required=True, collection_name='authors') # This adds a query-object as an attribute named 'books' to Author entities. author = db.ReferenceProperty(Author, required=True, collection_name='books') </code></pre> <p>Also, if <code>BookAuthor</code> does not have additional properties, make sure you look at the list-of-keys method outlined in the article you referenced.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload