LeoneBacciu / django-email-verification

A Django app that takes care of verifying a users's email address and activating their profile.
MIT License
356 stars 56 forks source link

NoReverseMatch with custom url #83

Open jslovern391 opened 1 year ago

jslovern391 commented 1 year ago

I was curious if anyone is looking at this because I have an issue.

LeoneBacciu commented 1 year ago

Yes, I recently started maintaining this project again. What issue do you have?

jslovern391 commented 1 year ago

When using this it marks the user as active, but that is the page it goes to afterward.

\Python\Python311\Lib\site-packages\verify_email\views.py, line 58, in verify_user_and_activate

'link': reverse(login_page) ^^^^^^^^^^^^^^^^^^^

jslovern391 commented 1 year ago

Screenshot_20230901_171426_GitHub.jpg

jslovern391 commented 1 year ago

By the way, this is a really nice app

LeoneBacciu commented 1 year ago

I'm sorry but I don't understand the issue, could you be more specific?

jslovern391 commented 1 year ago

When the user clicks the verification link, that is the page that displays. I am assuming it should be the successful page.

LeoneBacciu commented 1 year ago

I'm guessing it might be a conflict with the app verify_email, can you share your urls configuration?

jslovern391 commented 1 year ago

Yes when I get home tonight

jslovern391 commented 1 year ago

I sent a verification email and then redirected to http://127.0.0.1:8000/accounts/login/. The user is created and is set to inactive. When the user clicks the verification email they are marked active and this page is shown to them.

NoReverseMatch at /verification/user/verify-email/anNsb3Zlcm5AZ21haWwuY29t/YnR3YWd4LWQ2ZGEwNGY4YWRkYzY4MDljNmIxMjE4NDEwZTE5NTMzOjFxY1JjbjpIcWRXNzFwclEwUW1fNnB3NE5MTUdsTmVsNFBQcmVmZjg4bnhkdFdYQmtF/

Reverse for '/accounts/login/' not found. '/accounts/login/' is not a valid view function or pattern name.
Request Method: | GET -- | -- http://127.0.0.1:8000/verification/user/verify-email/anNsb3Zlcm5AZ21haWwuY29t/YnR3YWd4LWQ2ZGEwNGY4YWRkYzY4MDljNmIxMjE4NDEwZTE5NTMzOjFxY1JjbjpIcWRXNzFwclEwUW1fNnB3NE5MTUdsTmVsNFBQcmVmZjg4bnhkdFdYQmtF/ 4.2.4 NoReverseMatch Reverse for '/accounts/login/' not found. '/accounts/login/' is not a valid view function or pattern name. C:\Users\rtbr1\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\urls\resolvers.py, line 828, in _reverse_with_prefix verify_email.views.verify_user_and_activate C:\Users\rtbr1\AppData\Local\Programs\Python\Python311\python.exe 3.11.4 ['D:\\M28t\\Django Project\\m28t', 'C:\\Users\\rtbr1\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip', 'C:\\Users\\rtbr1\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 'C:\\Users\\rtbr1\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 'C:\\Users\\rtbr1\\AppData\\Local\\Programs\\Python\\Python311', 'C:\\Users\\rtbr1\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages'] Sat, 02 Sep 2023 14:29:43 +0000

Traceback Switch to copy-and-paste view

  • C:\Users\rtbr1\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\handlers\exception.py, line 55, in inner
    1.                 response = get_response(request)
                                     ^^^^^^^^^^^^^^^^^^^^^
    Local vars
  • C:\Users\rtbr1\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\handlers\base.py, line 197, in _get_response
    1.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Local vars
  • C:\Users\rtbr1\AppData\Local\Programs\Python\Python311\Lib\site-packages\verify_email\views.py, line 58, in verify_user_and_activate
    1.                     'link': reverse(login_page)
                                      ^^^^^^^^^^^^^^^^^^^
    Local vars
  • C:\Users\rtbr1\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\urls\base.py, line 88, in reverse
    1.     return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Local vars
  • C:\Users\rtbr1\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\urls\resolvers.py, line 828, in _reverse_with_prefix
    1.         raise NoReverseMatch(msg)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
    Local vars

#################################################################### INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',

############################################
'member.apps.MemberConfig',
'verify_email.apps.VerifyEmailConfig',
'crispy_bootstrap4',
'crispy_forms',

urlpatterns = [ path('', views.index, name='index'), path('member//', views.MemberDetail.as_view(),name='member_detail'), path('create_org/', views.OrgCreate.as_view(),name='create_org'), path('login/', views.login, name='login'), path('logout/', views.logout, name='logout'), path('signup/', views.signup, name='signup'), ]

views.py def signup(request): if request.method == 'POST': form = MemberForm(request.POST) if form.is_valid(): inactive_user = send_verification_email(request, form) form.cleaned_data['email'] username = form.cleaned_data.get('username') email = form.cleaned_data.get('email') ######################## mail system ####################################

htmly = get_template('fish/Email.html')

        # d = { 'username': username }
        # subject, from_email, to = 'welcome', 'messages@dev-m28tmessages.com', email
        # html_content = htmly.render(d)
        # msg = EmailMultiAlternatives(subject, html_content, from_email, [to])
        # msg.attach_alternative(html_content, "text/html")
        # msg.send()
        ##################################################################
        messages.success(request, f'Verification email has been sent.  Please check spam folder.')
        return redirect('login')
else:
    form = MemberForm()
return render(request, 'member/signup.html', {'form': form, 'title':'register here'})
jslovern391 commented 1 year ago

Sorry wrong urls.py

urlpatterns = [ path('admin/', admin.site.urls), ####################################### path('', RedirectView.as_view(url='member/signup')), path('member/', include('member.urls')), path('accounts/', include('django.contrib.auth.urls')), path('verification/', include('verify_email.urls')), ]

LeoneBacciu commented 1 year ago

Ok, I understand better now. A couple of things:

  1. Are you sure you are using the latest version? v0.3.1
  2. Please, use the 'Add Code' on github, the error is extremely hard to read. You could also add the html file.
  3. It seems there is a problem with the resolution of the url, but you say that the user gets activated, are you sure?
  4. Have you followed the documentation here to add the token verification url?