1

統合後に次のエラーが発生します

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'

助けてください!

EDIT EDIT 私のトレースバック

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.
4

1 に答える 1

1

create_profile シグナルが起動されていないか (シグナル ファイルは django 機械のどこかからインポートされていますか?)

または、新しい create_profile シグナル ハンドラーをまだ実行していない既存のユーザーがいます。

トレースバックを投稿すると常に役立ちます。

于 2012-11-27T07:22:54.073 に答える