On Dec 28, 6:33 am, "Ms. Jen" <[email protected]> wrote:
>
> I have been struggling with attempting to run a datastore query and
> keep getting the same error even though I have read through all the
> docs on Queries and Keys, watching several of the Google I/O videos,
> as well as looking at a number other apps' source code to see how they
> are done.
This bit doesn't make sense:
> id = int(self.request.get('id'))
> band_id = Band.get(db.Key.from_path('Band', id))
Band.get(key) returns a model, not an 'id'. But there is an easier
way:
a_band_instance = Band.get_by_id(id)
Given the above, this next section doesn't make sense because you
already have a band object:
> if band_id:
> band_query = Band.gql("WHERE ID = ", id)
> band = band_query.fetch(1)
Unless you specifically created an 'ID' attribute in your Band model,
you are probably mistaking it for the built-in '__key__' attribute,
which is what get() and get_by_id() use in the first example.
if not band_instance:
# The 'id' you are passing in is wrong.
# Where did you get it from?
You could log in to the admin interface and use the data browser to
double-check what Band models you have saved.
--
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.