Skip to content

Instantly share code, notes, and snippets.

@martin-martin
Created August 7, 2018 10:00
Show Gist options
  • Save martin-martin/b642467f0c03d1555dd30f9b589cc2ab to your computer and use it in GitHub Desktop.
Save martin-martin/b642467f0c03d1555dd30f9b589cc2ab to your computer and use it in GitHub Desktop.
Django templates: show authentication links depending on user authentication status
<!DOCTYPE html>
<html>
<head>
<title>nameme</title>
</head>
<body>
<nav>
<!-- below block allows to show/hide authentication info
depending on user's authentication status -->
{% if not user.is_authenticated %}
<a href="/signup">Sign Up</a>
<a href="/login">Log In</a>
{% endif %}
{% if user.is_authenticated %}
<a href="/logout">Log Out</a>
{% endif %}
</nav>
{% block content %}
{% endblock content %}
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment