尝试使用Facebook登录Django服务器时出现内部服务器错误

时间:2015-04-13 06:06:19

标签: django facebook django-rest-framework django-allauth django-rest-auth

我有一个Django REST服务器,我最近使用Python 2.7到3.4进行了更新。服务器在Django之上使用Django REST框架,django-allauth和django-rest-auth用于Facebook登录支持。

现在,更新后,我再也无法使用Facebook登录服务器了。当我向服务器发送POST时,出现以下错误:

Internal Server Error: /rest-auth/facebook/
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\django\core\handlers\base.py", line 132, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Python34\lib\site-packages\django\views\decorators\csrf.py", line 58, in wrapped_view return view_func(*args, **kwargs)
  File "C:\Python34\lib\site-packages\django\views\generic\base.py", line 71, in view return self.dispatch(request, *args, **kwargs)
  File "C:\Python34\lib\site-packages\rest_framework\views.py", line 452, in dispatch response = self.handle_exception(exc)
  File "C:\Python34\lib\site-packages\rest_framework\views.py", line 449, in dispatch response = handler(request, *args, **kwargs)
  File "C:\Python34\lib\site-packages\rest_auth\views.py", line 51, in post if not self.serializer.is_valid():
  File "C:\Python34\lib\site-packages\rest_framework\serializers.py", line 187, in is_valid self._validated_data = self.run_validation(self.initial_data)
  File "C:\Python34\lib\site-packages\rest_framework\serializers.py", line 370, in run_validation value = self.validate(value)
  File "C:\Python34\lib\site-packages\rest_auth\registration\serializers.py", line 31, in validate token.account = login.account
  File "C:\Python34\lib\site-packages\django\db\models\fields\related.py", line 668, in __set__ (value, self.field.rel.to._meta.object_name)
  File "C:\Python34\lib\site-packages\django\db\models\base.py", line 496, in __repr__ u = six.text_type(self)
  File "C:\Python34\lib\site-packages\allauth\socialaccount\models.py", line 104, in __str__ return force_text(self.user)
  File "C:\Python34\lib\site-packages\django\db\models\fields\related.py", line 608, in __get__ "%s has no %s." % (self.field.model.__name__, self.field.name)
django.db.models.fields.related.RelatedObjectDoesNotExist: SocialAccount has no user.
[13/Apr/2015 08:53:30]"POST /rest-auth/facebook/ HTTP/1.1" 500 115908

可能导致这种情况的原因是什么?在更新Python和库之后,我没有对代码进行任何更改,并且在更新之前它已经工作。我删除了旧数据库并通过syncdb创建了一个新数据库,但它没有帮助。

提前致谢。

1 个答案:

答案 0 :(得分:0)

已在Django 1.8中删除

RelatedObject,转而使用ForeignObjectRelSource

您使用的allauth版本不支持Django 1.8。