What is the difference b/w authenticate() and login() in Django?

时间:2017-12-18 05:40:49

标签: python django django-authentication

I want to understand the difference b/w both

user = authenticate(
    username=form.cleaned_data.get('username'),
    password=form.cleaned_data.get('password1')
)
login(request, user)

1 个答案:

答案 0 :(得分:1)

The authenticate() method accepts username and password and validates if the the credentials entered are those of valid user. If yes, it returns an user object.

The Login method takes an HttpRequest object and auth_user object . and Logs the user in and binds him not only to the request object but also in Session.