May 2020
Intermediate to advanced
404 pages
10h 52m
English
To create the login page, we'll need to add the /login route to urls.py in the billboard app. However, we've already done that. Next, we need to add the loginView view to the views.py file of the billboard app:
def loginView(request): if request.user.is_authenticated: return redirect('/') else: if request.POST: username = request.POST['username'] password = request.POST['password'] user = authenticate(request, username=username, password=password) ## MORE CODE BELOW THIS LINE ## MORE CODE ABOVE THIS LINE else: return redirect('/logout') else: template = loader.get_template('login.html') context = {} return HttpResponse(template.render(context, request))
The preceding function first checks whether the username and ...
Read now
Unlock full access