Hi,
Guido explained very clearly how to do
here<http://stackoverflow.com/questions/11122846/whats-the-alternative-to-back-reference-property-in-ndb>
.

Just add a property to the Post class

    @property
    def comments(self):
        return Comment.query(Comment.post == self.key)

-- Gianni


On Mon, Dec 31, 2012 at 2:26 AM, Toto <emays...@gmail.com> wrote:

> In my previous GAE app, I had something like a blog (Post and related
> Comment)
> Posts and Comments where 2 different models such as
>
> class Post(db.Model):
>     headline = db.StringProperty(required = True)
>     content = db.TextProperty(required = True)
>
> class Comment(db.Model):
>     """ Comment object with many-to-one relationship """
>     content = db.TextProperty(required = True)
>     post = db.ReferenceProperty(Post, collection_name='comment_set')
>
> Now with db, thanks to the collection_name, I could easily find the
> comments referring to a post ( aka back reference) using post.comment_set
>
> How are now back references handled in ndb?
> Is there a preferred method?
>
> Regards
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/_W5mhfhwqBEJ.
> To post to this group, send email to google-appengine@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to