Skip to content

Commit

Permalink
handle validators being a list (#1648)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstacey authored and pennersr committed Mar 5, 2017
1 parent 5b14a43 commit f0feeeb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions allauth/account/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,19 +296,18 @@ def USERNAME_VALIDATORS(self):
from django.core.exceptions import ImproperlyConfigured
from allauth.utils import import_attribute
from allauth.utils import get_user_model

path = self._setting('USERNAME_VALIDATORS', None)
if path:
ret = import_attribute(path)
ret = []
validators = self._setting('USERNAME_VALIDATORS', None)
if validators:
for path in validators:
ret.append(import_attribute(path))
if not isinstance(ret, list):
raise ImproperlyConfigured(
'ACCOUNT_USERNAME_VALIDATORS is expected to be a list')
else:
if self.USER_MODEL_USERNAME_FIELD is not None:
ret = get_user_model()._meta.get_field(
self.USER_MODEL_USERNAME_FIELD).validators
else:
ret = []
return ret


Expand Down

0 comments on commit f0feeeb

Please sign in to comment.