2017-03-20 134 views
0

我想檢查用戶的電子郵件驗證狀態以顯示警告消息。如果電子郵件地址未驗證,我會在頁面頂部顯示一條消息。電子郵件地址驗證狀態

是否有任何用於檢查用戶電子郵件地址的模板標籤被確認?

+2

你嘗試過什麼到目前爲止?你在用戶模型中有驗證字段嗎?發佈一些代碼進行審查。 –

+0

正在使用django-allauth @TimS。 –

回答

0

您可以使用custom template tags,驗證相同,如下圖所示:

app_tags.py

from django import template 

register = template.Library() 

@register.assignment_tag 
def verify_email(email): 
    ... 
    if email_verified: 
     return True 
    else 
     return False 

example.html的

{% load app_tags %} 
... 
{% verify_email email as email_verified %} 
{% if email_verified %} 
    do something 
{% endif %} 
+0

謝謝你的評論,但我正在使用django-allauth。驗證是這個包中的一個模塊。 –