haha, yep, thanks Sal. For those wondering, that hate stackoverflow/links,
the problem (it seems) was that my custom function wasn't converting the
value to a str. This seems to work
class Comment(db.Model):
series = db.ReferenceProperty(reference_class=Series);
def series_id(self):
return str(self._series.id())
in the template:
<a href="games/view-series.html?series={{comment.series_id}}#comm{{
comment.key.id}}">more</a>
This seems to get me the id without hitting the database. If this is
*wrong*, PLEASE let me know :)
Thanks all!
On Sat, Sep 27, 2008 at 12:37 AM, Sal <[EMAIL PROTECTED]> wrote:
>
> Just here to spread the knowledge :D
>
>
> http://stackoverflow.com/questions/141973/how-do-i-get-the-key-value-of-a-dbreferenceproperty-without-a-database-hit
>
>
> On Sep 26, 7:52 pm, theo <[EMAIL PROTECTED]> wrote:
> > You could change db.ReferenceProperty to db.ListProperty(db.Key) and
> > only ever put one item in the list.
> >
> > Alternatively, you could store the key in a string and just db.Key()
> > it every time.
> >
> > On Sep 26, 2:03 pm, "Chris Marasti-Georg" <[EMAIL PROTECTED]>
> > wrote:
> >
> > > Is there a way to get the key (or id) value of a db.ReferenceProperty,
> > > without dereferencing the actual entity it points to? I have been
> digging
> > > around - it looks like the key is stored as the property name preceeded
> with
> > > an _, but I have been unable to get any code working. Examples would
> be
> > > much appreciated. Thanks
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---