topless
topless

Reputation: 8221

Sorting collection_name in appengine

class Profile(db.Model):
    user = db.UserProperty()

class Playlist(db.Model):
    name = db.StringProperty()
    profile = db.ReferenceProperty(Profile, collection_name='playlists')
    videos_num = db.IntegerProperty(default=0)

This are the basic entities of my model. I can access the playlists like profile.playlists but how can I have them sorted according to their videos_num?

Upvotes: 1

Views: 330

Answers (1)

Wooble
Wooble

Reputation: 89847

profile.playlists is just a db.Query. Call its .order('videos_num') method.

Upvotes: 3

Related Questions