1๐
{% block sidebar %}
<p>
{% if user.is_authenticated %}
<a href = "/accounts/login/"><button>Login</button></a>
<a href = "/accounts/profile/"><button>User Profile</button></a>
<a href = "/admin/"> <button>Site Administration</button></a>
{% else %}
<a href = "/accounts/register/"><button>Account Registrration</button></a>
{% endif %}
</p>
{% endblock %}
To hide it completely, which in my humble opinion is better than having it be visible and disabled ๐
BTW. your code as pasted is missing the closing </a>
tags
0๐
Just use
{% if user.is_authenticated %}
<a><button disabled>Login</button> </a>
{% else %}
<a href = "/accounts/login/"><button>Login</button> </a>
{% endif %}
in your base.html
. Even if there are derived templates, the logged in status will be available to them and this would work as expected.
๐คarocks
- [Answer]-Django blog app that uses pygments and works like StackOverflow
- [Answer]-How do I find where a django template variable comes from in the python
- [Answer]-Sending url parameter to generic view which sends it to an element in a ModelForm
- [Answer]-How to Install new_relic into django application running under apache and mod_wsgi
Source:stackexchange.com