Hi,

I think you are trying to filter the ReferenceProperty as a string,
this won't work. You need to;

query.filter('owner = ', PetOwner.all().filter('name =', 'johndoe'))

Doc on the Datastore ReferenceProperty;

http://code.google.com/appengine/docs/python/datastore/entitiesandmodels.html#References

Thanks,
Arun Shanker Prasad.

On Sep 15, 8:54 am, PatHaugen <[email protected]> wrote:
> Jumping into GAE, I found the ReferenceProperty interesting but still
> don't fully understand it.
>
> My question can expand on the example 
> from:http://code.google.com/appengine/docs/python/datastore/creatinggettin...
>
> class PetOwner(db.Model):
>   name = db.StringProperty()
> class Pet(db.Model):
>   name = db.StringProperty()
>   type = db.StringProperty() # cat, dog, etc.
>   owner = db.ReferenceProperty(PetOwner)
>
> Let's do a query to select all cats with a specific owner.
>
> query = db.Query(Pet)
> query = Pet.all()
> query.filter('type = ', 'Cat')
> results = query.fetch(limit=10)
> for result in results:
>   output = result.name
> return output
>
> What can I add to this to filter only those where 'owner' is
> 'johndoe'?
>
> I tried:
> query.filter('owner = ', 'johndoe')
>
> However it fails to return me a result, and I know you can pull the
> owner name via 'pet.owner.name' however trying:
> query.filter('owner.name = ', 'johndoe')
>
> Also fails, though it made sense for what should work. Does anyone
> know the proper method?
--~--~---------~--~----~------------~-------~--~----~
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