I am using conventional email code generation to verify email users. During development when I send the verification link to console and paste in browser it works fine but during production it says page not found.. Have tried all possible option no result. Kindly check the code below
Validation view
def activate(request, uidb64, token):
try:
uid = force_text(urlsafe_base64_decode(uidb64))
user = User.objects.get(pk=uid)
except(TypeError, ValueError, OverflowError, User.DoesNotExist):
user = None
if user is not None and account_activation_token.check_token(user, token):
user.is_active = True
user.save()
messages.success(request, 'Thank you for your email confirmation. Now you can login your account.')
return redirect('user-login')
URL
path('activate/(P<uidb64>[0-9A-Za-z_\-] )/(P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/',
user_views.activate, name='activate'),
Email code format Please click on the link to confirm your registration, http://example.com/activate/(PMTI[0-9A-Za-z_\-] )/(Pb6ymqe-66b9346a42751b6d94e729b4050698ba[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/
Kindly assist with the issue
Page not found (404) Request Method: GET Request URL: https://example.com/activate/(PMTI[0-9A-Za-z_%5C-]%2b)/(Pb6ymqe-66b9346a42751b6d94e729b4050698ba[0-9A-Za-z]%7B1,13%7D-[0-9A-Za-z]%7B1,20%7D)/
activate/(P[0-9A-Za-z_-] )/(P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/ [name='activate'] ^media/(?P.*)$ The current path, activate/(PMTI[0-9A-Za-z_\-]+)/(Pb6ymqe-66b9346a42751b6d94e729b4050698ba[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/, didn’t match any of these.
CodePudding user response:
You need to do it like this, in your urls.py
:
path('activate/<uidb64>/<token>/', user_views.activate, name='activate')