1

I am new to django and trying to integrate django_facebook api in my django website that i am currently running on localhost. I am getting an error saying A server error occurred. Please contact the administrator.I have attached the error log and other files so that it can help in figuring out the cause of error.

urls.py

from django.conf.urls import patterns, url, include

from . import views

app_name='polls'
urlpatterns = [
    url(r'^$', views.IndexView.as_view(), name='index'),
    url(r'^(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'),
    url(r'^(?P<pk>[0-9]+)/results/$', views.ResultsView.as_view(), name='results'),
    url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),
    url(r'^facebook/', include('django_facebook.urls')),
    url(r'^accounts/', include('django_facebook.auth_urls')),
]

error-log

Traceback (most recent call last):
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/home/shivani/newproject/newenv/lib/python3.4/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/home/shivani/newproject/newenv/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 158, in __call__
    self.load_middleware()
  File "/home/shivani/newproject/newenv/lib/python3.4/site-packages/django/core/handlers/base.py", line 53, in load_middleware
    mw_instance = mw_class()
TypeError: facebook() missing 1 required positional argument: 'request'
[03/Jan/2016 15:02:41] "GET /favicon.ico HTTP/1.1" 500 59

settings.py

""" Django settings for mysite project.

    Generated by 'django-admin startproject' using Django 1.9.

    For more information on this file, see
    https://docs.djangoproject.com/en/1.9/topics/settings/

    For the full list of settings and their values, see
    https://docs.djangoproject.com/en/1.9/ref/settings/
    """

    import os

    # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = '3qx%oiuq@zyb@f)bnnk3-j4cnt&1p=o#&8bxx5l))wwkn@c!)r'

    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = True

    ALLOWED_HOSTS = []


    # Application definition

    INSTALLED_APPS = [
        'polls.apps.PollsConfig',
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django_facebook',
    ]

    MIDDLEWARE_CLASSES = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
        'django_facebook.context_processors.facebook',
        'django.core.context_processors.request',
    ]

    AUTHENTICATION_BACKENDS = (
        'django_facebook.auth_backends.FacebookBackend',
        'django.contrib.auth.backends.ModelBackend',
    )


    AUTH_USER_MODEL = 'django_facebook.FacebookCustomUser'

    AUTH_PROFILE_MODULE = 'django_facebook.FacebookProfile'

    ROOT_URLCONF = 'mysite.urls'

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [],
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                    'django_facebook.context_processors.facebook',
                    'django.core.context_processors.request',
                ],
            },
        },
    ]

    WSGI_APPLICATION = 'mysite.wsgi.application'


    # Database
    # https://docs.djangoproject.com/en/1.9/ref/settings/#databases

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        }
    }


    # Password validation
    # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators

    AUTH_PASSWORD_VALIDATORS = [
        {
            'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
        },
    ]


    # Internationalization
    # https://docs.djangoproject.com/en/1.9/topics/i18n/

    LANGUAGE_CODE = 'en-us'

    TIME_ZONE = 'Asia/Kolkata'

    USE_I18N = True

    USE_L10N = True

    USE_TZ = True


    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/1.9/howto/static-files/

    STATIC_URL = '/static/'


    #facebook details

    FACEBOOK_APP_ID = 'something'
    FACEBOOK_APP_SECRET = 'something'

I am unable to figure out the reason of the error.

0 Answers0