Thanks Robert! That is so unexpectedly simple - I hadn't realised that
I had a query object - or that I could order by the dates like that.

On Feb 24, 8:05 pm, Robert Kluin <[email protected]> wrote:
> Brian,
>   I just re-read your thread more carefully.  I think what you want to
> know is simply:
> reel_frames = reel.frames.order('auto_now_add_prop.order')
>
>   'frames' on Reel (created by the reference property from Frames) is
> just a query object.
>
> Robert
>
> On Wed, Feb 24, 2010 at 3:01 PM, Robert Kluin <[email protected]> wrote:
> > Alex,
> >  You can only order by properties on the model itself.  If you want
> > to order by a property on a referenced model, you need to include it.
> > So in your case you might want to add a "reelName" property to Frame,
> > then just be sure you handle updating that property when you change
> > the name on Reel.
>
> > Robert
>
> > On Wed, Feb 24, 2010 at 9:09 AM, Alex <[email protected]> wrote:
> >> Hi,
> >> Is it possible to do anything with a reference property other than
> >> cycle through the referenced objects in whatever order they are
> >> returned? For example I have a number of reference properties to
> >> instances where the creation date is crucial to how they are
> >> subsequently managed. Is there a way to order the result?
>
> >> class Reel(db.Model):
> >>   name = db.StringProperty()
>
> >> class Frame(db.Model):
> >>    # datetime.datetime.now() when the object is first created.
> >>    auto_now_add_prop = db.DateTimeProperty(auto_now_add=True)
> >>    # reference to the one and only reel this frame belong to
> >>    reel = db.ReferenceProperty(Reel, collection_name='frames')
>
> >> I would like to order 'reel.frames' depending on the
> >> 'auto_now_add_prop' date. Is this the right way to access these
> >> instances if date order access is frequent and  crucial?
> >> The Frame model will have millions of instances so a query there
> >> matching for a given Reel instance would be expensive. Ideas/advice/a
> >> thread I haven't seen?
>
> >> Alex
>
> >> --
> >> 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 
> >> athttp://groups.google.com/group/google-appengine?hl=en.

-- 
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