Nick, once again YOU are my HERO!!!!!! THX so much!
For the help of others who may need this I summarize:
if passing numeric ID's in URLs(i.e. from key().id() or django
request.user.key.id) to query with filters do as below:
.filter('user =', db.Key.from_path('your model',int(numeric key))
Once again, thx so much!
Dave
On May 1, 9:47 am, "Nick Johnson (Google)" <[email protected]>
wrote:
> On Fri, May 1, 2009 at 2:19 PM, Dave <[email protected]> wrote:
>
> > Wow, thx for the super fast respone Nick. You're the best.
>
> > So I am probably still confused. I tried the following:
>
> > queryset = get_list_or_404(Album, 'user =',db.Key.from_path
> > ('User',key))
> > where key = 2. I get "Names may not begin with a digit; received %s.'
> > % id_or_name)"
>
> > This leads be to beleive it's trying to pull a key_name vs. an ID.
>
> This will be the case if you got 'key' straight from a query parameter
> - it's a numeric string, rather than a number. Cast it to a number
> with int() and you should be fine.
>
> > I'm not sure how to use the get_by_id since I'm looking to filter by a
> > reference property of User within the Album model that points to User.
> > It seems Album.get_by_id would return a single album record. I'm
> > looking to get all Albums for a specific user.
>
> Ah, I see. My mistake. :)
>
>
>
> > thx,
>
> > On May 1, 9:03 am, "Nick Johnson (Google)" <[email protected]>
> > wrote:
> >> Hi Dave,
>
> >> You have two options here: Construct a Key object from the ID and kind,
> >> like so:
>
> >> db.Key.from_path('Album', id)
>
> >> or you can use the convenience method get_by_id on a Model class:
>
> >> Album.get_by_id(id).
>
> >> -Nick Johnson
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---