-
Notifications
You must be signed in to change notification settings - Fork 341
Open
Description
I have set up email verification as obligatory in the Allauth settings and as the documentation suggests created a new url with VerifyEmailView. However, I'm getting django.core.exceptions.ImproperlyConfigured: TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()' whenever I click the link that is sent to the mail.
Here is the email I got:
Hello from [example.com](http://example.com/)!
You're receiving this email because user test_username has given your email address to register an account on [example.com](http://example.com/).
To confirm this is correct, go to http://localhost:8000/api/auth/registration/account-confirm-email/MTI:1rDwxE:pQfOORIY0AOZN0AeweHmqOLDx2TmgVapR2V5y3Jruk4/
urls.py:
urlpatterns = [
path("admin/", admin.site.urls),
path("api/posts/", (include("posts.urls"))),
path("api/accounts/", (include("accounts.urls"))),
path("api/auth/", include("dj_rest_auth.urls")),
path("api/auth/registration/", include("dj_rest_auth.registration.urls")),
path(
"api/auth/registration/account-confirm-email/",
VerifyEmailView.as_view(),
name="account_email_verification_sent example 1",
),
path(
"api/auth/account-confirm-email/",
VerifyEmailView.as_view(),
name="account_email_verification_sent example 2",
),
path(
"api/auth/",
VerifyEmailView.as_view(),
name="account_email_verification_sent example 3",
),
]settings.py:
from pathlib import Path
from dotenv import load_dotenv
import os
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
SECRET_KEY = os.environ.get("SECRET_KEY")
DEBUG = os.environ.get("DEBUG")
ALLOWED_HOSTS = []
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"allauth",
"allauth.account",
"allauth.socialaccount",
"dj_rest_auth.registration",
"rest_framework",
"rest_framework.authtoken",
"accounts",
"posts",
]
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",
"allauth.account.middleware.AccountMiddleware",
]
ROOT_URLCONF = "core.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"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 = "core.wsgi.application"
# Database
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Auth
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",
},
]
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": ("dj_rest_auth.jwt_auth.JWTCookieAuthentication",)
}
REST_AUTH = {
"LOGIN_SERIALIZER": "dj_rest_auth.serializers.LoginSerializer",
"TOKEN_SERIALIZER": "dj_rest_auth.serializers.TokenSerializer",
"JWT_SERIALIZER": "dj_rest_auth.serializers.JWTSerializer",
"JWT_SERIALIZER_WITH_EXPIRATION": "dj_rest_auth.serializers.JWTSerializerWithExpiration",
"JWT_TOKEN_CLAIMS_SERIALIZER": "rest_framework_simplejwt.serializers.TokenObtainPairSerializer",
"USER_DETAILS_SERIALIZER": "accounts.serializers.AccountSerializer",
"PASSWORD_RESET_SERIALIZER": "dj_rest_auth.serializers.PasswordResetSerializer",
"PASSWORD_RESET_CONFIRM_SERIALIZER": "dj_rest_auth.serializers.PasswordResetConfirmSerializer",
"PASSWORD_CHANGE_SERIALIZER": "dj_rest_auth.serializers.PasswordChangeSerializer",
# /////
"REGISTER_SERIALIZER": "dj_rest_auth.registration.serializers.RegisterSerializer",
"REGISTER_PERMISSION_CLASSES": ("rest_framework.permissions.AllowAny",),
# /////
"TOKEN_MODEL": "rest_framework.authtoken.models.Token",
"TOKEN_CREATOR": "dj_rest_auth.utils.default_create_token",
# /////
"PASSWORD_RESET_USE_SITES_DOMAIN": False,
"OLD_PASSWORD_FIELD_ENABLED": True,
"LOGOUT_ON_PASSWORD_CHANGE": False,
"SESSION_LOGIN": True,
"USE_JWT": False,
# /////
"JWT_AUTH_COOKIE": "maskotapp",
"JWT_AUTH_REFRESH_COOKIE": None,
"JWT_AUTH_REFRESH_COOKIE_PATH": "/",
"JWT_AUTH_SECURE": True,
"JWT_AUTH_HTTPONLY": True,
"JWT_AUTH_SAMESITE": "Lax",
"JWT_AUTH_RETURN_EXPIRATION": False,
"JWT_AUTH_COOKIE_USE_CSRF": False,
"JWT_AUTH_COOKIE_ENFORCE_CSRF_ON_UNAUTHENTICATED": False,
}
# Email
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
EMAIL_HOST = os.getenv("EMAIL_HOST")
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_PORT = 587
EMAIL_USE_TLS = True
# Internationalization
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
STATIC_URL = "static/"
# Default primary key field type
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
AUTH_USER_MODEL = "accounts.User"Traceback:
Internal Server Error: /api/auth/registration/account-confirm-email/MTI:1rDwxE:pQfOORIY0AOZN0AeweHmqOLDx2TmgVapR2V5y3Jruk4/
Traceback (most recent call last):
File "C:\python_example\backend\.venv\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "C:\python_example\backend\.venv\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python_example\backend\.venv\Lib\site-packages\django\views\generic\base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python_example\backend\.venv\Lib\site-packages\django\views\generic\base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python_example\backend\.venv\Lib\site-packages\django\views\generic\base.py", line 227, in get
return self.render_to_response(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python_example\backend\.venv\Lib\site-packages\django\views\generic\base.py", line 200, in render_to_response
template=self.get_template_names(),
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python_example\backend\.venv\Lib\site-packages\django\views\generic\base.py", line 212, in get_template_names
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'
ThukuWakogi and JAM-Beni
Metadata
Metadata
Assignees
Labels
No labels