-6

我正在编写这样的 MongoDB 查询: Message.objects.filter( Q(author_id=user.id) | Q(for_user_id=user.id) | Q( shared_with_id=user.id)).order_by( "-timestamp") [:10]

版本是

MongoDB = 1.8.2 Pymonogo:1.11

Traceback (most recent call last):

File "/mnt/install/wwm/thirdparty/django/core/handlers/base.py", line 100, in    get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/mnt/install/wwm/thirdparty/django/contrib/auth/decorators.py", line 25, in _wrapped_view
return view_func(request, *args, **kwargs)

 File "/mnt/install/wwm/main/views.py", line 1232, in user_messages
 mesg_list = list(Message.objects( Q(author_id=user.id) | Q(for_user_id=user.id) | Q( shared_with_id=user.id)).order_by( "-timestamp")[:10])

 File "/mnt/install/wwm/thirdparty/mongoengine/queryset.py", line 223, in call
 self._where_clause = q_obj.as_js(self._document)

  File "/mnt/install/wwm/thirdparty/mongoengine/queryset.py", line 89, in as_js
  return pymongo.code.Code(' '.join(js), js_scope)

 AttributeError: 'module' object has no attribute 'code'

同一行代码在 pymongo 上运行良好:2.0.1 mongodb:2.1.0

由于我不想更新 pymongo,您能说出错误的确切位置或任何解决方法吗?

谢谢

4

1 回答 1

2

正如github上提到的:

Pymongo 1.11 不再受支持。如果可能,我建议更新 pymongo。如果不可能,您需要查看导入,因为代码和其他已移至 bson 模块。

您使用的是什么版本的 MongoEngine?

于 2012-05-28T10:27:41.400 回答