我使用django_norel並遵循所有的安裝方向,但我得到這個錯誤:Django_norel錯誤「DatabaseWrapper」對象有沒有屬性「經營者」的AppEngine
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」)並且工作。所以我猜這是加入和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,因爲我試圖避免谷歌的應用程序內發動機不會讓你做連接。我對django_norel的需求感到困惑。
這裏的蟒蛇錯誤代碼:如果
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'
我可以運行測試的任何想法?我很想重新安裝所有東西...... – flo 2011-04-21 19:40:38