userprofile匹配查询不存在django facebook错误

时间:2012-11-27 06:20:39

标签: django django-models django-facebook

我在整合

后收到以下错误

来自/ facebook / connect /的DoesNotExist UserProfile匹配查询不存在。

这是我的models.py

from django.db import models


from django_facebook.models import FacebookProfileModel

from django.contrib.auth.models import User


class UserProfile(FacebookProfileModel):

    user = models.OneToOneField(User)


from django.db.models.signals import post_save

from django.dispatch import receiver

@receiver(post_save, sender=User)

def create_profile(sender, instance, created, **kwargs):


    if created: 

        profile, new = UserProfile.objects.get_or_create(user=instance)

也在我的设置中

AUTH_PROFILE_MODULE = 'kk.UserProfile'

请帮助!

修改 编辑我的追溯

Environment:


Request Method: POST
Request URL: http://localhost:8000/facebook/connect/?facebook_login=1

Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django_facebook',
 'kk')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view
  77.         return view_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_facebook-4.0.8-py2.7.egg/django_facebook/utils.py" in wrapper
  358.         response = f(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_facebook-4.0.8-py2.7.egg/django_facebook/decorators.py" in _wrapped_view
  89.                 get_persistent_graph(request, redirect_uri=current_uri)
File "/usr/local/lib/python2.7/dist-packages/django_facebook-4.0.8-py2.7.egg/django_facebook/api.py" in get_persistent_graph
  61.         graph = get_facebook_graph(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_facebook-4.0.8-py2.7.egg/django_facebook/api.py" in get_facebook_graph
  181.                 profile = request.user.get_profile()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py" in get_profile
  400.                                    self._state.db).get(user__id__exact=self.id)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in get
  366.                     % self.model._meta.object_name)

Exception Type: DoesNotExist at /facebook/connect/
Exception Value: UserProfile matching query does not exist.

1 个答案:

答案 0 :(得分:1)

您的create_profile信号是否未被触发(是从django机器中某处导入的信号文件?)

或者您现有的用户尚未运行新的create_profile信号处理程序。

发布追溯始终有帮助。