def login(request):
    """
    Log a user in.
    """
    if request.method == 'POST':
        form = AuthenticationForm(data=request.POST)
        if form.is_valid():
            login_user(request, form.get_user())
            return redirect(request.GET['next'] if 'next' in request.GET else 'home')
    else:
        form = AuthenticationForm()
    return render(request, 'accounts/login.html', {
        'title': 'Login',
        'form': form,
        'action': 'Login',
    })
dataset/ETHPy150Open 2buntu/2buntu-blog/twobuntu/accounts/views.py/login/original