New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle validators being a list #1648
Conversation
For now I have reverted this, according to the current documentation/implementation it was a path to a list, and not directly a list itself. I do agree, that may be unexpected, we need to reassess this, but as is now changing this would break backwards compatibility. |
I referenced this in #1658. What's the best way to implement this? You said it's a path to a list, but where should that list reside, if not in the settings module? |
I closed my other issue to avoid a lack of redundancy, but here are the contents:I'm trying to use the Battlenet BattletagUsernameValidator However, Django is throwing errors no matter which way I write it. If my settings.py contains:
I get an error that ACCOUNT_USERNAME_VALIDATORS must be a list. If I amend this I get an error about django six.string_types. Here is the error I'm currently getting:
My settings.py looks like:
|
@biddellns I think settings needs a path and the path has to point to a list. So like: foobar/settings.py
then create foobar/validators.py with:
|
Ahh that makes sense! I know that's a really basic solution, but I was stuck on that problem for a while. Thank you for the guidance! |
I'm actually still having trouble tracking this down and I'm not sure why python is being so weird about it. Django was still complaining when I used a method to return a list. So I just hardcoded a list instead and it was able to pick that up. Unfortunately, it still won't pick up the validator. I'm getting this error and I've double and triple checked
My validators file looks like:
My app structure looks like
It's definitely picking up my validators file. And I verified the 'socialaccount/providers/battlenet/validators' path. Any ideas? |
yes... The reason the top one isn't working is that you're returning a list with a string in it rather than the actual validator object. I think you want something like:
|
I finally got it working! I had to write my import the validators as you described. However returning the function still didn't work. For anyone looking, I used this in 'myapp/settings/validators.py':
Thanks @alexstacey! |
@biddellns great! working fine! Thanks. |
This fixes a bug when setting USERNAME_VALIDATORS.
USERNAME_VALIDATORS is a list of paths which fails when passed to import_attribute() - so instead pass each path in the list to import_attribute().