Hi,
I am sorry I replied to the thread when I was not at my dev machine, did not
test the code. I am not sure if putting the query inside the query.filter()
will break it.

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

This should work.

Thanks,
Arun Shanker Prasad.


On Wed, Sep 16, 2009 at 12:50 AM, PatHaugen <[email protected]> wrote:

>
> I tested the filter you provided:
> query.filter('owner = ', PetOwner.all().filter('name =', 'johndoe'))
>
> However it didn't work.
>
> I visited the doc you referenced, but the page does not mention
> anything about the style of query filters or any information on
> construction of queries with ReferenceProperty that I could find.
>
> Does the query filter you wrote work on your side?
>
> I broke our your query:
> PetOwner.all().filter('name =', 'johndoe')
>
> Which worked fine, however it was in placing it inside the
> query.filter that I get an error.
>
> Do you not get an error structured like this?
>
> On Sep 15, 4:36 am, Arun Shanker Prasad <[email protected]>
> wrote:
> > 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/entitiesandmod...
> >
> > 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