When an unauthenticated user, visits the home page. He would be displayed a page not found there. You may not want like that, instead the user can be redirected to the login page.
This can be done be editing the @login_required
decorator as follows :
@login_required(login_url='login')
def home(request):
return render(request, 'home.html')
Here along with the decorator, the login_url
is set to redirect the user to the login page.
So now, if an unauthenticated user visits the home page he will be automatically redirected to the login page.
The
next
in the url indicates the page to which the user actually wanted to visit, but he wasn't able to visit it as he was not authenticated.