集成后出现以下错误
DoesNotExist at /facebook/connect/ 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.