Learn Django

Update Base Template & Settings

The login/logout functionality is now completely built. The only thing left to do is update the base.html file to include the correct links. Follow these steps to update the template file.

Step 1: Update Template

Open /.../crmeasy/crmapp/templates/base.html in your IDE and update the two lines as follows.

1
2
3
4
5
(old line)
<li><a href="">Logout</a></li>

(new line)
<li><a href="/logout/">Logout</a></li>

and

1
2
3
4
5
(old line)
<li><a href="">Login</a></li>

(new line)
<li><a href="/login/">Login</a></li>

Step 2: Update Settings

We can also configure Django to redirect users to a specific page after they login. Add this setting to the end of the settings.py file to direct the users to the account list upon login.

1
LOGIN_REDIRECT_URL = '/account/list/'

Step 3: Commit Changes

Execute these commands to commit your changes in Git.

1
2
3
4
5
# add files
(venv)$ git add .

# commit files
(venv)$ git commit -m "update base template with login & logout links"

Track your progress with a free account