gpt4 book ai didi

python - PyAMF 数据库错误 : 'This query is not supported by the database.' when returning the User object

转载 作者:太空宇宙 更新时间:2023-11-04 06:37:54 25 4
gpt4 key购买 nike

这是我遇到的错误:

ERROR    2011-11-19 04:19:55,441 django.py:164] Error encoding AMF request
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/remoting/gateway/django.py", line 161, in __call__
logger=self.logger, timezone_offset=timezone_offset)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/remoting/__init__.py", line 676, in encode
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/remoting/__init__.py", line 520, in _write_body
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/remoting/__init__.py", line 486, in _encode_body
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/codec.py", line 499, in writeElement
func(data)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/amf0.py", line 657, in writeAMF3
self.context.getAMF3Encoder(self).writeElement(data)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/codec.py", line 499, in writeElement
func(data)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/amf3.py", line 1456, in writeObject
self.writeElement(value)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/codec.py", line 499, in writeElement
func(data)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/amf3.py", line 1298, in writeList
[self.writeElement(x) for x in n]
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/codec.py", line 499, in writeElement
func(data)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/codec.py", line 358, in __call__
ret = self.func(data, encoder=self.encoder)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/adapters/_django_db_models_base.py", line 276, in writeDjangoObject
encoder.writeObject(referenced_object)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/amf3.py", line 1468, in writeObject
self.writeElement(value)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/codec.py", line 499, in writeElement
func(data)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/codec.py", line 358, in __call__
ret = self.func(data, encoder=self.encoder)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/adapters/_django_db_models_base.py", line 276, in writeDjangoObject
encoder.writeObject(referenced_object)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/amf3.py", line 1468, in writeObject
self.writeElement(value)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/codec.py", line 499, in writeElement
func(data)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/codec.py", line 358, in __call__
ret = self.func(data, encoder=self.encoder)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/adapters/_django_db_models_base.py", line 276, in writeDjangoObject
encoder.writeObject(referenced_object)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/amf3.py", line 1447, in writeObject
attrs = alias.getEncodableAttributes(obj, codec=self)
File "/Library/Python/2.6/site-packages/PyAMF-0.6.1-py2.6-macosx-10.6-universal.egg/pyamf/adapters/_django_db_models_base.py", line 173, in getEncodableAttributes
attrs[name] = [x for x in getattr(obj, name).all()]
File "/Users/bryce/Documents/Aptana Studio 3 Workspace/django-blog/django/db/models/query.py", line 107, in _result_iter
self._fill_cache()
File "/Users/bryce/Documents/Aptana Studio 3 Workspace/django-blog/django/db/models/query.py", line 774, in _fill_cache
self._result_cache.append(self._iter.next())
File "/Users/bryce/Documents/Aptana Studio 3 Workspace/django-blog/django/db/models/query.py", line 275, in iterator
for row in compiler.results_iter():
File "/Users/bryce/Documents/Aptana Studio 3 Workspace/DennysBE/djangotoolbox/db/basecompiler.py", line 225, in results_iter
self.check_query()
File "/Users/bryce/Documents/Aptana Studio 3 Workspace/DennysBE/djangotoolbox/db/basecompiler.py", line 273, in check_query
raise DatabaseError('This query is not supported by the database.')
DatabaseError: This query is not supported by the database.

以下是我对这个问题很重要的模型:

class ChallengeAct(models.Model):
challenge = models.ForeignKey(Challenge, blank=True, null=True)
user = models.ForeignKey(User, blank=True, null=True)
start_date = models.DateTimeField(blank=True, null=True)
progress_value = models.IntegerField(default=0)
earned_coupon = models.ForeignKey(EarnedCoupon, blank=True, null=True)

这是导致错误的方法:

def foo_bar(request):
user = request.user
c = ChallengeAct()
c.challenge = Challenge.objects.get(id=1)
c.start_date = datetime.now()
c.progress_value = 1
c.user = user
c.save()

# Here is where I set the user to null to avoid the DatabaseError
c.user = None
return [c]

有趣的是,我需要在返回之前设置 c.user = None,这样我就不会得到 DatabaseError: This query is not supported by the database . 问题。

--update-- 越想越觉得是pyamf和django-nonrel获取用户对象的问题。我猜测当 pyamf 尝试获取用户对象时,它正在使用某种类型的连接查询,而 django-nonrel 不支持这种类型。

这是为什么?有解决办法吗?

最佳答案

您不必为用户模型允许 blank=True, null=True。通常 django.contrib.auth.models.AnonymousUser 会处理匿名请求。它可能会或可能不会解决问题,但值得尝试,即:

class ChallengeAct(RewardActBase):
user = models.ForeignKey(User)
....

关于python - PyAMF 数据库错误 : 'This query is not supported by the database.' when returning the User object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8191976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com