Django_norel错误'DatabaseWrapper'对象没有属性'运算符'appengine

时间:2011-04-20 04:00:59

标签: django google-app-engine

我正在使用django_norel并遵循所有安装说明,但我收到此错误:

 Exception Value:   
     'DatabaseWrapper' object has no attribute 'operators'

当我转到以下视图(返回昵称的JSON对象)时:

def listUsers(request, thread_id):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login/')
    else:       
        thread_user_list = UserProfile.objects.filter(user=UsersThreads.objects.filter(thread=thread_id).values('pk'))
        data = serializers.serialize( 'json', thread_user_list, ensure_ascii=False, fields=('nickname'))
        return HttpResponse(data)  

我要做的就是发送一个线程用户的JSON对象。

它肯定与过滤器有关,因为我尝试简单地返回HttpResponse(“asdf”)并且有效。所以我猜这是Joining和norel数据库的问题。当我在sqlite数据库上运行时,这个代码有效(可能在调试时过滤器功能发生了一些变化)。

以下是我的模特:

 class UserProfile(models.Model):
    nickname = models.CharField(max_length=25)
     user = models.ForeignKey(User, unique=True)
     facebook_id = models.CharField(max_length=200)
     def __unicode__(self):
     return self.nickname

 class Thread(models.Model):
    name = models.CharField(max_length=200)
    tagline = models.CharField(max_length=200)
    founder = models.ForeignKey(UserProfile)
    pub_date = models.DateTimeField('date published')
    def __unicode__(self):
        return self.name

 class UsersThreads(models.Model):
    thread = models.ForeignKey(Thread)
    user = models.ForeignKey(UserProfile)
    def __unicode__(self):
        return self.thread.name

我创建了UsersThreads,因为我试图避免google-app-engine不让你加入。我对django_norel的需求感到困惑。

这是python错误代码:

Environment:


Request Method: GET
Request URL: http://localhost:8000/users/4/

Django Version: 1.3
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'djangotoolbox',
 'dbindexer',
 'djangoappengine']
Installed Middleware:
('dbindexer.middleware.DBIndexerMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.csrf.CsrfResponseMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/Users/asdf/threadchat_main/django/core/handlers/base.py" in get_response
  111.response = callback(request, *callback_args, **callback_kwargs)
File "/Users/asdf/threadchat_main/threadchat/views.py" in listUsers
  162.         data = serializers.serialize( 'json', thread_user_list, ensure_ascii=False, fields=('nickname'))
File "/Users/asdf/threadchat_main/django/core/serializers/__init__.py" in serialize
  91.     s.serialize(queryset, **options)
File "/Users/asdf/threadchat_main/django/core/serializers/base.py" in serialize
  39.         for obj in queryset:
File "/Users/asdf/threadchat_main/django/db/models/query.py" in _result_iter
  107.                 self._fill_cache()
File "/Users/asdf/threadchat_main/django/db/models/query.py" in _fill_cache
  774.                     self._result_cache.append(self._iter.next())
File "/Users/asdf/threadchat_main/django/db/models/query.py" in iterator
  275.         for row in compiler.results_iter():
File "/Users/asdf/threadchat_main/djangotoolbox/db/basecompiler.py" in results_iter
  219.         for entity in self.build_query(fields).fetch(low_mark, high_mark):
File "/Users/asdf/threadchat_main/djangotoolbox/db/basecompiler.py" in build_query
  278.         query.add_filters(self.query.where)
File "/Users/asdf/threadchat_main/djangotoolbox/db/basecompiler.py" in add_filters
  73.                 self.add_filters(child)
File "/Users/asdf/threadchat_main/djangotoolbox/db/basecompiler.py" in add_filters
  76.             column, lookup_type, db_type, value = self._decode_child(child)
File "/Users/asdf/threadchat_main/djangotoolbox/db/basecompiler.py" in _decode_child
  87.         packed, value = constraint.process(lookup_type, value, self.connection)
File "/Users/asdf/threadchat_main/django/db/models/sql/where.py" in process
  329.                     connection=connection, prepared=True)
File "/Users/asdf/threadchat_main/django/db/models/fields/subclassing.py" in inner
  53.             return func(*args, **kwargs)
File "/Users/asdf/threadchat_main/django/db/models/fields/related.py" in get_db_prep_lookup
  156.                 sql, params = value._as_sql(connection=connection)
File "/Users/asdf/threadchat_main/django/db/models/query.py" in _as_sql
  941.             return obj.query.get_compiler(connection=connection).as_nested_sql()
File "/Users/asdf/threadchat_main/django/db/models/sql/compiler.py" in as_nested_sql
  136.         return obj.get_compiler(connection=self.connection).as_sql()
File "/Users/asdf/threadchat_main/django/db/models/sql/compiler.py" in as_sql
  68.         where, w_params = self.query.where.as_sql(qn=qn, connection=self.connection)
File "/Users/asdf/threadchat_main/django/db/models/sql/where.py" in as_sql
  92.                     sql, params = child.as_sql(qn=qn, connection=connection)
File "/Users/asdf/threadchat_main/django/db/models/sql/where.py" in as_sql
  95.                     sql, params = self.make_atom(child, qn, connection)
File "/Users/asdf/threadchat_main/django/db/models/sql/where.py" in make_atom
  171.         if lookup_type in connection.operators:
File "/Users/asdf/threadchat_main/dbindexer/base.py" in __getattr__
  9.         return getattr(self._target, name)
File "/Users/asdf/threadchat_main/django/utils/_threading_local.py" in __getattribute__
  183.             return object.__getattribute__(self, name)

Exception Type: AttributeError at /users/4/
Exception Value: 'DatabaseWrapper' object has no attribute 'operators'

1 个答案:

答案 0 :(得分:0)

不确定是否是您的安装。当我尝试做一个django-nonrel“加入”时,我遇到了同样的问题。也许您可以首先通过首先获取主键并确认您的请求是正确的来简化thread_user_list的代码。