0

I have a django project with a customUser model (email / password), and I'm trying to get email verification links working. They were working before, but now for some reason the path is failing. When you sign up for an account on my site you get an email with a registration-confirmation URL like so:

http://127.0.0.1:8000/rest-auth/registration/account-confirm-email/OA:1hxEiC:mbXKk8-is0YJz2FKHd_1d62KNv8/

But when you click this url, it leads to an error page with the message:

ImproperlyConfigured at /rest-auth/registration/account-confirm-email/OA:1hxEiC:mbXKk8-is0YJz2FKHd_1d62KNv8/
TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'

my main urls.py file has a urlpatterns list which looks like this:

    urlpatterns = [
#admin page
path('admin/', admin.site.urls),
path('playlist/', include(('playlist.urls', 'playlist'), namespace='playlist')),
#users
path('users/', include('django.contrib.auth.urls')),
#accounts (allauth)
path('accounts/', include('allauth.urls')),
...
#django-rest-auth
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
#bug reports for this issue online point to a solution like so, but this isn't fixing the error
url(r"^rest-auth/registration/account-confirm-email/(?P<key>[\s\d\w().+-_',:&]+)/$", allauthemailconfirmation, name="account_confirm_email"),
#jwt
url(r'^refresh-token/', refresh_jwt_token),
]

Can somebody please help me figure out this error? I have looked at many other instances of this problem being posted online and have found many people solving it by catching the registration-confirmation path using a regular expression, I've tried every regex combination I could find in solutions posted online but haven't had any luck solving the problem. I always get the same error when I click the email confirmation link.

Any help is very much appreciated, thx

Martin
  • 1,336
  • 4
  • 32
  • 69

1 Answers1

0

It would seem you view allauthemailconfirmation uses a TemplateResponseMixin which requires template_name to be defined. You haven't. So in your view, add it. Something like

class allauthemailconfirmation(TemplateResponseMixin, whateverClassesDeclared):
    template_name = 'path/to/filename.html'
    ...
HenryM
  • 5,557
  • 7
  • 49
  • 105
  • i tried adding this but am still getting the same error, I changed my primary urls.py to include "url(r"^rest-auth/registration/account-confirm-email/(?P[\s\d\w().+-_',:&]+)", include('users.urls'), name="account_confirm_email")," and in my urls.py for my users app added "urlpatterns = [ path('', allauthemailconfirmation.as_view()), ]" , which goes to my views.py file which has "class allauthemailconfirmation(TemplateView): template_name = 'pages/home.html'" , but im still getting the same template error – Martin Aug 12 '19 at 21:14