Reputation: 642
Why does the Django authenticate function work only with this?
user=authenticate(
username=request.POST['username'],
password=request.POST['password']
)
And not with
user=authenticate(
request.POST['username'],
request.POST['password']
)
Upvotes: 2
Views: 84
Reputation: 11316
There can be many different authentication backends and they might use a different way of authentication than with username and password, i.e. some kind of token. To keep authenticate()
method generic, it had to be implemented this way.
Official documentation says "It takes credentials as keyword arguments, username and password for the default case." The key part is: for the default case.
The only argument that can be given as positional argument is the optional request
argument.
Upvotes: 3