我正在编写这样的 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,您能说出错误的确切位置或任何解决方法吗?
谢谢