2017-03-05 127 views
0

我向包含uuidd(activation_token)的用戶發送激活電子郵件,當用戶單擊電子郵件中的鏈接時,我得到一個無法找到的eroror 404頁面。django電子郵件帳戶活動

電子郵件代碼

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

UUID的代碼示例

51094a477a14-4e26a7c84bff8b63a94d 

URL在瀏覽器

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

Url瀏覽器與url模式不同'/ accounts /' – alfredo138923

+0

您將令牌作爲GET參數傳遞。應該是'/ account_activation/51094a477a14-4e26a7c84bff8b63a94d /' –

回答

1

您的激活令牌不接受連字符,並且僅匹配單個字符。它應該是:

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

請注意,您可以將其從a-z更改爲a-f,因爲令牌是uuid。

相關問題