[Fixed]-How could one disable new account creation with django-allauth, but still allow existing users to sign in?

34👍

The question rnevius linked to fixed this for me. To add a bit more detail, I created a file mysite/account_adapter.py containing:

from allauth.account.adapter import DefaultAccountAdapter

class NoNewUsersAccountAdapter(DefaultAccountAdapter):

    def is_open_for_signup(self, request):
        """
        Checks whether or not the site is open for signups.

        Next to simply returning True/False you can also intervene the
        regular flow by raising an ImmediateHttpResponse

        (Comment reproduced from the overridden method.)
        """
        return False

And then added this to mysite/settings.py:

ACCOUNT_ADAPTER = 'mysite.account_adapter.NoNewUsersAccountAdapter'

Leave a comment