After I changed user model to using email instead of username, email is not sending when I access rest-auth.registration.views.RegisterView
.
What should I do to make working?
My email setup is:
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
It's correct configuration, sending email on rest_auth.views.PasswordResetView
works fine.
users/urls.py:
app_name = "users"
urlpatterns = [
path("register/", include("rest_auth.registration.urls")),
...
]
config/urls.py:
from allauth.account.views import AccountInactiveView
urlpatterns = [
...
path("api/v1/users/", include("myproject.users.urls")),
# this url is used to generate email content
# https://github.com/Tivix/django-rest-auth/blob/master/demo/demo/urls.py
path("password-reset/<uidb64>/<token>/", TemplateView.as_view(), name="password_reset_confirm")
# for some reason required for rest-auth register view working
path("account-inactive/", AccountInactiveView.as_view(), name="account_inactive"),
]
config/settings.py
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_USERNAME_REQUIRED = False
After accessing register view, there's no error. User object is created and response (code 201) is:
{
"detail": "Verification e-mail sent."
}
However there's no email sent.
Thanks for help!
I solved this problem. The problem occurred because default value for is_active
field in User
model was False
. And for some reason allauth
and rest-auth
do not allow to send activation email for inactive user.