-
Notifications
You must be signed in to change notification settings - Fork 673
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
Issue when Authentication fails: __init__() takes from 1 to 2 positional arguments but 3 were given #144
Comments
Did you solve this issuer? |
Reviving issue, any ideas? |
@naelmusleh @haristimuno-omnibnk @hvitis I’m not sure where the problem could lie to be honest IN GENERAL. But if you take a look at the original def validate, it already returns something... so having token = super() doesn’t really make (at first glance, it seemed like an infinite loop, but I guess not). You’re getting this because you’ve supplied validate with super().validate(attrs) which in turn makes the serializer’s validate method use self.validate(attrs, attrs) which is giving you this error. So instead of using super(), rewrite the entire validate method. Another theory which is not as good since the above is probably the correct identification of the problem: Based on traceback error, you’re missing the whole “not authenticated part” as in the default:
If you take a look at what the original problem was, we have a default “no_account_account” error that should’ve been raised, but I suppose wasn’t based on the original poster’s serializer... which shouldn’t have touched the validation part to be honest. |
@Andrew-Chen-Wang @naelmusleh @haristimuno-omnibnk 🎉 🎊 Fixed it. 🎉 🎊 I was unnecessarily adding the extended, customized serializer to my settings. Now my extending process looks like this: No need to change anything in settings. |
I have the following in my views.py
And in my serializers.py
When Authentication is successful, data is returned with no issues. But when Authentication fails, instead of getting a JSON with the error message, I get the following Django Exception:
__init__() takes from 1 to 2 positional arguments but 3 were given
Traceback:
The text was updated successfully, but these errors were encountered: