[英]How to manipulate only certain element belonging to an object list in Pandas DataFrame
[英]How to make allauth accept only gmail addresses belonging to a certain institute?
例:-
qwe123 @ pilani.bits-pilani.ac.in
我想我只需要檢查電子郵件地址中是否存在“模板結尾”,但問題是在allauth包中要檢查的地方
據我所知,在django-allauth中沒有直接的方法可以做到這一點。 最好的選擇是監聽user_signed_up信號,並禁用沒有所需電子郵件地址格式的帳戶。
from allauth.account.signals import user_signed_up
from django.dispatch import receiver
@receiver(user_signed_up)
def after_user_signed_up(request, user):
if user.email.endswith('pilani.bits-pilani.ac.in'):
# do something for valid accounts
else :
user.is_active = False
user.save()
# raise SomeException
如果您有多個地址模式,則將需要多個if語句,或者可能為允許的電子郵件地址模式創建一個模型。
沒有直接的方法可以做到這一點。 但是,肯定有很少的間接方法。 您可以使用電子郵件標頭進行檢查。 從這里您可以獲取有關電子郵件的基本信息。 您可以存儲ip address
並使用該ip address
過濾特定域。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.