본문 바로가기

Django

Django all-auth 로그인 연동

반응형

https://django-allauth.readthedocs.io/en/latest/installation.html

 

Installation — django-allauth 0.43.0 documentation

Post-Installation In your Django root execute the command below to create your database tables: Now start your server, visit your admin pages (e.g. http://localhost:8000/admin/) and follow these steps: Add a Site for your domain, matching settings.SITE_ID

django-allauth.readthedocs.io

 

1. all-auth 설치

  • pip install django-allauth

2. settings.py > INSTALLED_APPS에 아래 추가

    # The following apps are required:
    'django.contrib.auth',
    'django.contrib.messages',
    'django.contrib.sites',

    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.google',

3. settings.py에 아래 추가

AUTHENTICATION_BACKENDS = [
    # Needed to login by username in Django admin, regardless of `allauth`
    'django.contrib.auth.backends.ModelBackend',

    # `allauth` specific authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
]

SITE_ID = 1

4. Email 확인을 위해 settings.py에 아래 추가

https://django-allauth.readthedocs.io/en/latest/configuration.html

 

Configuration — django-allauth 0.43.0 documentation

Controls whether or not information is revealed about whether or not a user account exists. For example, by entering random email addresses in the password reset form you can test whether or not those email addresses are associated with an account. Enablin

django-allauth.readthedocs.io

ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'none'

5. url.py 에 url 추가하기

urlpatterns = [
    ...
    path('accounts/', include('allauth.urls')),
    ...
]

6. migration 하기

python manage.py migrate

 

반응형

'Django' 카테고리의 다른 글

secret key 생성  (0) 2022.03.07
Markdownx 사용하기  (0) 2022.02.24
Django-crispy-form을 설치하기  (0) 2022.02.24
Python strip()  (0) 2022.02.24
Django Shell Plus  (0) 2022.02.22