django-allauth没有注册社交链接

时间:2018-04-03 05:01:06

标签: django django-allauth

当我在托管上部署我的网站时, django-allauth 发生了错误。我没有对django-allauth做任何事情。

这是我在localhost,django-allauth on localhost以及托管上获得的内容 django-allauth on hosting

我做了什么:

  1. 将我的网站下载到gitlab,该网站在localhost上工作,
  2. 通过git clone
  3. 将其下载到托管服务中
  4. 当然是建立venv。
  5. 我刚刚通过pip install django-allauth在托管中下载了 django-allauth 。没有 django-allauth 一切都运作良好。

    回溯:

    Environment:
    
    
    Request Method: GET
    Request URL: http://yakhshisarova.ru/
    
    Django Version: 2.0.3
    Python Version: 3.5.1
    Installed Applications:
    ['django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
     'django.contrib.sites',
     'widget_tweaks',
     'allauth',
     'allauth.account',
     'allauth.socialaccount',
     'allauth.socialaccount.providers.vk',
     'allauth.socialaccount.providers.instagram']
    Installed Middleware:
    ['django.middleware.security.SecurityMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.common.CommonMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware']
    
    
    Template error:
    In template /home/httpd/vhosts/yakhshisarova.ru/private/realestate/templates/authentication_links.html, error at line 3
       Reverse for 'vk_login' not found. 'vk_login' is not a valid view function or pattern name.
       1 : {% load socialaccount %}
       2 : 
       3 : <a href=" {% provider_login_url 'vk' method='oauth2' %} ">Войти с помощью ВКонтакте</a>
       4 : 
    
    Traceback:
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
      35.             response = get_response(request)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
      128.                 response = self.process_exception_by_middleware(e, request)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
      126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/realestate/realestate/index/views.py" in index
      15.         'filters_form': filters_form
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/shortcuts.py" in render
      36.     content = loader.render_to_string(template_name, context, request, using=using)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/loader.py" in render_to_string
      62.     return template.render(context, request)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/backends/django.py" in render
      61.             return self.template.render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in render
      175.                     return self._render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in _render
      167.         return self.nodelist.render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in render
      943.                 bit = node.render_annotated(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in render_annotated
      910.             return self.render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/loader_tags.py" in render
      155.             return compiled_parent._render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in _render
      167.         return self.nodelist.render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in render
      943.                 bit = node.render_annotated(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in render_annotated
      910.             return self.render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/loader_tags.py" in render
      194.                 return template.render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in render
      177.                 return self._render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in _render
      167.         return self.nodelist.render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in render
      943.                 bit = node.render_annotated(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/template/base.py" in render_annotated
      910.             return self.render(context)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/allauth/socialaccount/templatetags/socialaccount.py" in render
      39.         return provider.get_login_url(request, **query)
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/allauth/socialaccount/providers/oauth2/provider.py" in get_login_url
      11.         url = reverse(self.id + "_login")
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/urls/base.py" in reverse
      88.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
    
    File "/home/httpd/vhosts/yakhshisarova.ru/private/venv/lib/python3.5/site-packages/django/urls/resolvers.py" in _reverse_with_prefix
      632.         raise NoReverseMatch(msg)
    
    Exception Type: NoReverseMatch at /
    Exception Value: Reverse for 'vk_login' not found. 'vk_login' is not a valid view function or pattern name.
    

    setting.py

    """
    Django settings for realestate project.
    
    Generated by 'django-admin startproject' using Django 2.0.3.
    
    For more information on this file, see
    https://docs.djangoproject.com/en/2.0/topics/settings/
    
    For the full list of settings and their values, see
    https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/
    
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = 'dfgwe34tfQG%^UJ^&UH,kl/;l898'
    
    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = True
    
    ALLOWED_HOSTS = ['yakhshisarova.ru', '127.0.0.1']
    
    
    # Application definition
    
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django.contrib.sites',
    
        'widget_tweaks',
    
        'allauth',
        'allauth.account',
        'allauth.socialaccount',
        'allauth.socialaccount.providers.vk',
        'allauth.socialaccount.providers.instagram'
    ]
    
    AUTHENTICATION_BACKENDS = (
        'django.contrib.auth.backends.ModelBackend',
        'allauth.account.auth_backends.AuthenticationBackend',
    )
    
    ACCOUNT_EMAIL_REQUIRED = False
    
    SITE_ID = 1
    
    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ]
    
    ROOT_URLCONF = 'realestate.urls'
    
    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [
                os.path.join(BASE_DIR, 'templates'),
            ],
            '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',
                ],
            },
        },
    ]
    
    WSGI_APPLICATION = 'realestate.wsgi.application'
    
    
    # Database
    # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
    
    
    DATABASES = {
        'default': {
            'HOST': HOST,
            'ENGINE': 'django.db.backends.mysql',
            'NAME': DB_NAME,
            'USER': DB_USER,
            'PASSWORD': DB_PASSWORD,
        }
    }
    
    
    # Password validation
    # https://docs.djangoproject.com/en/2.0/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/2.0/topics/i18n/
    
    LANGUAGE_CODE = 'en-us'
    
    TIME_ZONE = 'UTC'
    
    USE_I18N = True
    
    USE_L10N = True
    
    USE_TZ = True
    
    
    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/2.0/howto/static-files/
    
    STATIC_URL = '/static/'
    STATICFILES_DIRS = [
       os.path.join(BASE_DIR, 'static'),
    ]
    
    LOGIN_REDIRECT_URL = 'index'
    LOGOUT_REDIRECT_URL = 'index'
    STATIC_ROOT = '/home/httpd/vhosts/yakhshisarova.ru/httpdocs/static'
    

    为什么会这样?

1 个答案:

答案 0 :(得分:0)

首先通过django管理员将vk添加为SocialApp。来自providers docs

  

您必须通过包含这些应用凭据的Django管理员为每个提供商添加SocialApp记录。