I want to prevent a user from seeing certain links on my navigation bar if the user is not logged in.
I am using the if statement in my template to do this. When I am logged in it shows the correct set of links but when I signed out it does not.
It should show the ul
with the sign in links. WHat am I doing wrong?
This is my code :
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
{% block head %}
{% endblock %}
</head>
<body>
<style>
ul, li {
margin: 0px 14px;
}
</style>
<nav class = "navbar fixed-top navbar-light bg-light justify-content-between flex-nowrap flex-row">
<div class = " container">
<a class = "navbar-brand float-left" href = "{% url 'Identities:nest'%}">nest</a>
{% if user.is_authenticated %}
<ul class = "nav navbar-nav flex-row float-left ">
<li class = "nav-item "><a class = "nav-link" href = "{% url 'Identities:logout'%}">Sign Out</a></li>
<li class = "nav-item"><a class = "nav-link" href = "{% url 'Identities:view_profile' %}">view Identity </a></li>
<li class = "nav-item"><a class = "nav-link" href = "{% url 'Identities:edit_profile' %}">edit Identity </a></li>
</ul>
{% else %}
<ul class = "nav navbar-nav flex-row float-left ">
<li class = "nav-item "><a class="nav-link" href = "{% url 'Identities:login'%}">Sign In</a></li>
</ul>
{% endif %}
</div>
</nav>
{% block body %}
{% endblock %}
</body>
</html>