8👍
There is no pre-configured setting but it’s easy to make one (this is what I do).
# settings.py
# Point to custom account adapter.
ACCOUNT_ADAPTER = 'myproject.myapp.adapter.CustomAccountAdapter'
# A custom variable we created to tell the CustomAccountAdapter whether to
# allow signups.
ACCOUNT_ALLOW_SIGNUPS = False
# myapp/adapter.py
from django.conf import settings
from allauth.account.adapter import DefaultAccountAdapter
class CustomAccountAdapter(DefaultAccountAdapter):
def is_open_for_signup(self, request):
"""
Whether to allow sign ups.
"""
allow_signups = super(
CustomAccountAdapter, self).is_open_for_signup(request)
# Override with setting, otherwise default to super.
return getattr(settings, 'ACCOUNT_ALLOW_SIGNUPS', allow_signups)
This is flexible, especially if you have multiple environments (e.g. staging) and want to allow user registration in staging before setting it live in production.
- Django RequestFactory file upload
- Debugging with pycharm, how to step into project, without entering django libraries
- Django ORM for desktop application
- Supervisorctl always reports error: ERROR (no such file)
- How to add a default array of values to ArrayField?
5👍
More information at http://django-allauth.readthedocs.io/en/latest/advanced.html#custom-redirects.
You need to subclass allauth.account.adapter.DefaultAccountAdapter
to override is_open_for_signup
, and then set ACCOUNT_ADAPTER
to your class in settings.py
👤Vic
- Django.core.paginator Ajax pagination with jQuery
- How to make trailing slash optional in django
- Adding link to django admin page
- Editing response content in Django middleware
Source:stackexchange.com