Custom Form Validation in Django-Allauth

荒凉一梦 提交于 2019-12-01 05:15:14

There are some adapters on the allauth configuration. For example this one:

ACCOUNT_ADAPTER (="allauth.account.adapter.DefaultAccountAdapter")
    Specifies the adapter class to use, allowing you to alter certain default behaviour.

You can specify a new adapter by overriding the default one. Just override the clean_email method.

class MyCoolAdapter(DefaultAccountAdapter):

    def clean_email(self, email):
        """
        Validates an email value. You can hook into this if you want to
        (dynamically) restrict what email addresses can be chosen.
        """
        *** here goes your code ***
        return email

Then modify the ACCOUNT_ADAPTER on the settings.py

ACCOUNT_ADAPTER = '**app**.MyCoolAdapter'

Check the default behavior on: https://github.com/pennersr/django-allauth/blob/master/allauth/account/adapter.py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!