I have installed django-facebook-4.0.8 for my website.The package is installed succesfully but giving different types of errors. Please help!
I am using AUTH_PROFILE_MODULE = 'django_facebook.FacebookProfile'.
It is registering the user as AUTH user but not registering it in django_facebook_facebookprofile table. After registering it gives the 'AnonymousUser' object has no attribute 'backend'
Here is my Traceback:
Environment:
Request Method: POST
Request URL: http://pydev.aviesta.com/facebook/connect/?facebook_login=1
Django Version: 1.4.2
Python Version: 2.6.6
Installed Applications:
['mezzanine.boot',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.redirects',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'cartridge.shop',
'mezzanine.conf',
'mezzanine.core',
'mezzanine.generic',
'mezzanine.blog',
'mezzanine.forms',
'mezzanine.pages',
'mezzanine.galleries',
'mezzanine.twitter',
'mezzanine.accounts',
'user_attr',
'facebook',
'django_facebook',
'django_extensions',
'filebrowser_safe',
'south',
'grappelli_safe',
'django.contrib.admin',
'django.contrib.comments']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'cartridge.shop.middleware.ShopMiddleware',
'mezzanine.core.request.CurrentRequestMiddleware',
'mezzanine.core.middleware.TemplateForDeviceMiddleware',
'mezzanine.core.middleware.TemplateForHostMiddleware',
'mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware',
'mezzanine.pages.middleware.PageMiddleware']
Traceback:
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
response = middleware_method(request, callback, callback_args, callback_kwargs) File "/usr/lib/python2.6/site-packages/mezzanine/pages/middleware.py" in process_view
return view_func(request, *view_args, **view_kwargs) File "/usr/lib/python2.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
return view_func(*args, **kwargs) File "/usr/lib/python2.6/site-packages/django_facebook/decorators.py" in _wrapped_view
return view_func(request, *args, **kwargs) File "/usr/lib/python2.6/site-packages/django_facebook/views.py" in connect
response = _connect(request, facebook_login) File "/usr/lib/python2.6/site-packages/django_facebook/views.py" in _connect
action, user = connect_user(request) File "/usr/lib/python2.6/site-packages/django_facebook/connect.py" in connect_user
user = _login_user(request, facebook, auth_user, update=False) File "/usr/lib/python2.6/site-packages/django_facebook/connect.py" in _login_user
login(request, authenticated_user) File "/usr/lib/python2.6/site-packages/django/contrib/auth/__init__.py" in login
request.session[BACKEND_SESSION_KEY] = user.backend File "/usr/lib/python2.6/site-packages/django/utils/functional.py" in inner
return func(self._wrapped, *args)
Exception Type: AttributeError at /facebook/connect/
Exception Value: 'AnonymousUser' object has no attribute 'backend'
basically you are calling
self.login(request, user)
without calling
authenticate(username=user, password=pwd)
first
when you call authenticate, django sets the backend attribute on the user, noting which backend to use, see here for more details https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.authenticate