Answer the question
In order to leave comments, you need to log in
How to connect the authorization module through the social network VKontakte allauth in django?
For half a day I can not connect the authorization module on the local host.
algorithm of actions
1. Installed the module
2. Created migrations
3. installed in INSTALLED_APPS
'allauth', # обычная авторизация
'allauth.account',
'allauth.socialaccount', # авторизация через социальные сети
'allauth.socialaccount.providers.vk',
# Настройка шаблонов
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',
],
},
},
]
# необходимые настройки для модуля авторизации пользователей
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
# вместо dummy ставим протокол smtp и тому подобный
EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
# Allauth список настроек для модуля авторизации
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_UNIQUE = True
# ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = True # обязательно ли подтверждение через электронную почту
ACCOUNT_AUTHENTICATION_METHOD = "username"
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 3 # время до подтверждения регистрации
ACCOUNT_EMAIL_VERIFICATION = "optional"
ACCOUNT_USERNAME_BLACKLIST = ["admin", "administrator", "moderator"] # имена которые нельзя использовать при регистрации
ACCOUNT_USERNAME_MIN_LENGTH = 4 # минимальное число символов при регистрации
ACCOUNT_USERNAME_REQUIRED = False
LOGIN_REDIRECT_URL = "/" # куда направить пользователя после авторизации
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = '/'
# ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True
# Provider specific settings настройки для входа через социальные сети
# SOCIALACCOUNT_PROVIDERS = {
# # 'vk': {
# # # For each OAuth based provider, either add a ``SocialApp``
# # # (``socialaccount`` app) containing the required client
# # # credentials, or list them here:
# # 'APP': {
# # }
# # }
# # }
{% extends "account/base.html" %}
{% load i18n %}
{% load account socialaccount %}
{% block head_title %}{% trans "Sign In" %}{% endblock %}
{% block content %}
{% load socialaccount %}
{% get_providers as socialaccount_providers %}
<a class="btn btn-social-icon btn-sm btn-vk" href="http://localhost/accounts/vk/login/callback/">
<span class="fa fa-vk">gggggggggggggggg</span>
</a>
<h1>{% trans "Sign In" %}</h1>
{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
<p>{% blocktrans with site.name as site_name %}Please sign in with one
of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
<div class="socialaccount_ballot">
<ul class="socialaccount_providers">
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
</ul>
<div class="login-or">{% trans 'or' %}</div>
</div>
{% include "socialaccount/snippets/login_extra.html" %}
{% else %}
<p>{% blocktrans %}If you have not created an account yet, then please
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
{% endif %}
<form class="login" method="POST" action="{% url 'account_login' %}">
{% csrf_token %}
{{ form.as_p }}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<a class="button secondaryAction" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
<button class="primaryAction" type="submit">{% trans "Sign In" %}</button>
</form>
{% endblock %}
Answer the question
In order to leave comments, you need to log in
In your table header, all elements are centered, and in the body of the table they are pressed to the left edge, either do text-align: left
it for th or text-align: center
for td
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question