嗨,我在这条线上出错。它在本地工作。
我只是删除了appspot上的所有实体。
#query line
sent_list = db.GqlQuery("SELECT email FROM MailListNew WHERE active = True")
#error line
sent_count = sent_list.count()
projection and keys_only cannot both be set
Traceback (most recent call last):
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
return handler.dispatch()
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~merdiven-mailservice/1.361030076545076265/index.py", line 89, in post
sent_count = sent_list.count()
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/db/__init__.py", line 2120, in count
result = raw_query.Count(limit=limit, **kwargs)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/datastore.py", line 1670, in Count
batch = self.GetBatcher(config=config).next()
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2671, in next
return self.next_batch(self.AT_LEAST_ONE)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2708, in next_batch
batch = self.__next_batch.get_result()
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 604, in get_result
return self.__get_result_hook(self)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2450, in __query_result_hook
self._batch_shared.conn.check_rpc_success(rpc)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1216, in check_rpc_success
raise _ToDatastoreError(err)
BadRequestError: projection and keys_only cannot both be set
最佳答案
您需要将查询更改为:
sent_list = db.GqlQuery("SELECT * FROM MailListNew WHERE active = True")
或更好):
sent_list = db.GqlQuery("SELECT __key__ FROM MailListNew WHERE active = True")
关于python - BadRequestError:投影和keys_only不能同时设置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11951037/