thomaSmith
thomaSmith

Reputation: 273

django email account activaiton

I am sending an activation email to the user containing a uuidd (activation_token), When the user clicks on the link in the email, I get an eroror 404 page cannot be found.

email code

accountactivation = AccountActivation(
                        email=email,
                        password=password
                    )
                accountactivation.save()
        subject = 'Account Confirmation'
            contact_message = 'please click the link to activate your account' + 'http://127.0.0.1:8000/accounts/account_activation/?activation_token=%s' %(accountactivation.activation_token)
            from_email = settings.EMAIL_HOST_USER
            to_email = from_email
            send_mail(subject,
                    contact_message,
                    from_email,
                    [to_email],
                    fail_silently=False,
                    )

url pattern

 url(r'^account_activation/(?P<activation_token>[0-9A-Za-z])/$', views.account_activation, name="account_activation"), 

uuid code example

51094a477a14-4e26a7c84bff8b63a94d

url in the browser

http://127.0.0.1:8000/accounts/account_activation/?id=51094a477a14-4e26a7c84bff8b63a94d/

Upvotes: 0

Views: 36

Answers (1)

Alasdair
Alasdair

Reputation: 308779

Your activation token does not accept hyphens, and it is only matching a single character. It should be:

(?P<activation_token>[0-9A-Za-z-]+)

Note you could change it from a-z to a-f since the token is a uuid.

Upvotes: 1

Related Questions