<a href='{% url logout %}{% if logout_to %}?next={{ logout_to }}{% endif %}'>{% trans "Log Out" %}</a>
{% else %}
{% url login as login_url %}
<a href='{% url logout %}{% if logout_to %}?next={{ logout_to }}{% endif %}'>{% trans "Log Out" %}</a>
{% else %}
{% url login as login_url %}