Here's how I would do it:

class Author(db.Model):
  """ set the key_name = user_id  when you create an Author
instance"""
  first_name = db.StringProperty()
  last_name = db.StringProperty()

class Post(db.Model):
  text = db.TextProperty()
  date = db.DateTimeProperty(auto_now_add=True)
  author = db.ReferenceProperty(Author, collection_name="posts")

# to get the author:
author = Author.get_by_key_name(users.get_current_user().user_id())
# to get five of the author's posts in reverse chronological order
(like a blog):
posts = author.posts.order("-date").fetch(5)

read more about the reference property here:
http://code.google.com/appengine/docs/python/datastore/entitiesandmodels.html#References

On Oct 15, 9:48 am, skywa1ker <[email protected]> wrote:
> I want to have very simple data structure.
>
> Users with properties: firsnane, lastname and posts with properties:
> author(user), text, creationdate. Like very simple guestbook.
>
> And i want to show all posts on a page ordered by creating date and
> with author name near the each post.
>
> For example i get all posts ( gql SELECT * FROM Post ), and now i need
> to get a author for each post?
>
> Is it any other way to get Author?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to