SQL Alchemy: Relationship with grandson
        Posted  
        
            by 
                giomasce
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by giomasce
        
        
        
        Published on 2011-06-24T15:02:12Z
        Indexed on 
            2011/06/24
            16:22 UTC
        
        
        Read the original article
        Hit count: 271
        
I'm building a SQL Alchemy structure with three different levels of objects; for example, consider a simple database to store information about some blogs: there are some Blog object, some Post object and some Comment objects. Each Post belongs to a Blog and each Comment belongs to a Post. Using backref I can automatically have the list of all Posts belonging to a Blog and similarly for Comments.
I drafted a skeleton for such a structure.
What I would like to do now is to have directly in Blog an array of all the Comments belonging to that Blog. I've tried a few approaches, but they don't work or even make SQL Alchemy cry in ways I can't fix. I'd think that mine is quite a frequent need, but I couldn't find anything helpful.
Colud someone suggest me how to do that?
Thanks.
© Stack Overflow or respective owner