0

I was making a web app on Django. I tried to send an email verification link to any new user who registers on my website. The thing works fine when I am hosting it on localhost but not upon hosting on AWS Elastic Beanstalk. The verification link generated fine. And I found a very similar issue.

Email Verification Fail in Django webapp hosted on Elastic Beanstalk

That answers to the case of appach. But I use nginx instead of appach.

settings.py

ACCOUNT_AUTHENTICATION_METHOD = 'username_email' 
ACCOUNT_USERNAME_REQUIRED = True
ACCOUNT_EMAIL_REQUIRED = True
LOGIN_REDIRECT_URL = 'timeline:index'
ACCOUNT_LOGOUT_REDIRECT_URL = 'account_login'
ACCOUNT_LOGOUT_ON_GET = True
ACCOUNT_EMAIL_SUBJECT_PREFIX = ''
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
ACCOUNT_UNIQUE_EMAIL = True
DEFAULT_FROM_EMAIL = 'tnajun@gmail.com'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' 
ACCOUNT_EMAIL_VERIFICATION = "mandatory" 
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

urls.py

from django.contrib import admin
from django.urls import path, re_path, include
from django.contrib.staticfiles.urls import static
from . import settings
from django.views.generic import RedirectView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('timeline.urls')),
    path('contact/', include('contact_form.urls')),
    path('accounts/email/', RedirectView.as_view(pattern_name='timeline:index')),
    path('accounts/inactive/', RedirectView.as_view(pattern_name='timeline:index')),
    path('accounts/password/change/', RedirectView.as_view(pattern_name='timeline:index')),
    path('accounts/confirm-email/', RedirectView.as_view(pattern_name='timeline:index')),
    path('accounts/', include('allauth.urls')),
    path('accounts/', include('accounts.urls')),
    re_path(r'^accounts/confirm-email/[^/]+/', RedirectView.as_view(pattern_name='timeline:index'), kwargs=None),
]

Procfile

web: gunicorn --bind :8000 --workers 3 --threads 2 config.wsgi:application

python3.7

Django==3.2.4

django-allauth==0.44.0

I tied ACCOUNT_EMAIL_VERIFICATION = "none" on EB and it works fine but that is not what I want.

Jun Tanaka
  • 11
  • 2

0 Answers0