Login and logout pages

Now that you can create users, you must create a login page to allow the user to authenticate. We must add the following URL in the urls.py file:

url(r'^connection$', 'TasksManager.views.connection.page', name="public_connection"),

You must then create the connection.py view with the following code:

from django.shortcuts import render from django import forms from django.contrib.auth import authenticate, login # This line allows you to import the necessary functions of the authentication module. def page(request): if request.POST: # This line is used to check if the Form_connection form has been posted. If mailed, the form will be treated, otherwise it will be displayed to the user. form = Form_connection(request.POST) if form.is_valid(): ...

Get Django: Web Development with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.