Ordani Sanchez Ordani Sanchez - 29 days ago 4x
Python Question

Structured Property or any better way?

I'm building a blog for a project and I'm saving all post in a entity kind like this:

class dbEntradas(ndb.Model):
title= ndb.StringProperty(required=True)
post= ndb.TextProperty(required=True)
topic= ndb.StringProperty(required=True)
user= ndb.StringProperty(required=True)

comentarios= ndb.StructuredProperty(dbComentarios, repeated=True)
#some others properties

Now all my posts must have comments, what I tried to did was to save the comments in a StructuredProperty repeated in this way:

post.comentarios=[dbComentarios(usuario=usuario, asunto=asunto,

This way only works if you have already created a instance of this property, but this just replace the old comment with the new one. What I want to do is to save all comments and these comments to be related with its post in the best possible way. Any suggestions?


A repeated property is basically a list so you can add a comment like this:

post.comentarios.append(dbComentarios(usuario=usuario, asunto=asunto,