>From modeling entity reference (one to many) document:
The phone_numbers virtual attribute is a Query instance, meaning that you
can use it to further narrow down and sort the collection associated with
the Contact. For example, if you only want to get the home phone numbers,
you can do this:
scott.phone_numbers.filter('phone_type =', 'home')
When Scott loses his phone, it's easy enough to delete that record. Just
delete the PhoneNumber instance and it can no longer be queried for:
scott.phone_numbers.filter('phone_type =', 'home').get().delete()
My question/problem: how can I get the list of phone numbers ordered by
created, suppose
class PhoneNumber(db.Model):
contact = db.ReferenceProperty(Contact,
collection_name='phone_numbers')
phone_type = db.StringProperty(
choices=('home', 'work', 'fax', 'mobile', 'other'))
number = db.PhoneNumberProperty()
created = db.DateTimeProperty(auto_now_add=True)
I tried:
scott.phone_numbers.order("-created").fetch(2)
but error is
NeedIndexError: no matching index found.
I tried:
fn = db.Query(PhoneNumber).filter('contact =',
'scot').order("-created").fetch(2)
but also does not work.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.