Well I have the problem, I can't log out when i just log in (without reloading the page). And I cant log in when I just logged out (again with page reload it works). Well I think after reloading the nav, he forgets the id of logout or something?
<script>
    logout = $('#logout')
    loginform = $('#loginform')
    logout.click(function () {
        $.ajax({
            url: 'accounts/logout/',
            success: function (json) {
                console.log(json)
                });
            },
        });
    });
    loginform.on('submit', function (event) {
        event.preventDefault();
        login();
    });
    function login() {
        $.ajax({
            url: 'accounts/login/',
            success: function (json) {
                console.log(json)
                /* Reloades the navbar */
                $('#usergui').load(document.URL + ' #usergui');
            }
        });
    }
    ;
</script>
My HTML:
<div id="usergui">
    <ul class="nav navbar-nav navbar-right">
        {% if user.is_authenticated %}
        <li><a id="logout"> </span>
                Logout
        </a></li> 
        {% else%}
        <li><a> </span>
                Login
        </a></li>
        <li><a> </span>
                Register
        </a></li> 
        {% endif %}
    </ul>
</div>
After Login my user gets authenticated and reloading the nav make only logout appear. The Element wasn't created dynamicaly-> it's static
 
     
    