Django18初体验


1242 浏览 5 years, 2 months

30 从导航栏登陆

版权声明: 转载请注明出处 http://www.codingsoho.com/

LOGIN FORM IN BOOTSTRAP NAVBAR

navbar.html

          {% if not request.user.is_authenticated and not "/accounts/login" in request.get_full_path %}
            <form class='navbar-form navbar-right' method='POST' action='{% url "auth_login" %}'>{% csrf_token %}
              <div class='form-group'>
                  <input type='text' class='form-control' name='username' placeholder='Username' /> 
              </div>
              <div class='form-group'>
                  <input type='password' class='form-control' name='password' placeholder='Password' />
              </div>
              <button type='submit' class='btn btn-default'>Login</button>
          </form>
          {% endif %}

这儿action的link action='{% url "auth_login" %}'就是前面的Login,这儿的用户名和密码的name也是一致的