Hi Zeynel, I don't use templates but as a guess i think you use result.mCOUNT To sort you can read the result in a list and sort on this or maybe the template engine has a solution for this. gr wim
On Wed, Nov 10, 2010 at 2:56 PM, Zeynel <azeyn...@gmail.com> wrote: > Can someone help me understand how to access the results of a query? > > This is my model: > > class Rep(db.Model): > mAUTHOR = db.UserProperty(auto_current_user=True) > mUNIQUE = db.StringProperty() > mCOUNT = db.IntegerProperty() > mDATE = db.DateTimeProperty(auto_now=True) > mDATE0 = db.DateTimeProperty(auto_now_add=True) > mWEIGHT = db.IntegerProperty() > > The app has a textarea form and user submits repetitions. mCOUNT is > the number of repetitions. I use this query to display top ten reps: > > QUERY = Rep.all() > QUERY.filter("mAUTHOR =", user) > QUERY.order("-mCOUNT") > RESULTS = QUERY.fetch(10) > > I display the results with Mako template: > > % for result in RESULTS: > <p>${result.mUNIQUE} (${result.mCOUNT})</p> > % endfor > > Instead of sorting by mCOUNT I want to sort by mWEIGHT so that an old > item with high count should be lower than a new item with lower count. > But the precise weighing formula is not important at this point. For > instance, it may be > > mWEIGHT = mDATE * mCOUNT > > What I do not understand is, how do I access mDATE and mCOUNT to put > them in the formula? I am having difficulty, in general, visualizing > the result of a query. The tutorial > http://code.google.com/appengine/docs/python/datastore/creatinggettinganddeletingdata.html#Getting_Entities_Using_a_Query > says that the query returns "the requested results as a list of model > instances." What is a "list of model instances?" And how to access > them as a variables in this context. Thanks for your help. > > -- > 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-appeng...@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. > > -- gr wdo Demo free E-business: https://e-comm.appspot.com Wim den Ouden Google App Engine (cloud) -- 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-appeng...@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.