('title') is not a tuple, you need to use ('title',) or ['title'] instead
>>> print ('title')
title
>>> print ('title',)
('title',)
>>>
On Tue, Apr 24, 2012 at 8:58 PM, Sun Jing <[email protected]> wrote:
> I tried to use projection queries:
>
> class Article(db.Model):
> title = db.StringProperty(required=True)
> # others...
>
> print db.Query('Article', projection=('title')).get()
>
>> Traceback (most recent call last):
>> File
>> "/base/python_runtime/python_lib/versions/1/google/appengine/ext/admin/__init__.py",
>> line 331, in post
>> exec(compiled_code, globals())
>> File "<string>", line 3, in <module>
>> File
>> "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py",
>> line 2098, in get
>> results = self.run(limit=1, **kwargs)
>> File
>> "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py",
>> line 2061, in run
>> raw_query = self._get_query()
>> File
>> "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py",
>> line 2446, in _get_query
>> kind = self._model_class.kind()
>> AttributeError: 'str' object has no attribute 'kind'
>
>
> print db.GqlQuery("SELECT title FROM Article").get().title
> # this one works
>
> --
> 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.
>
--
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.