现在实例了用户登陆,就自带的功能。。
urls.py
~~~~~~~~~~
(r‘^login/$‘, login),
(r‘^logout/$‘,logout,{‘next_page‘:‘/login/‘}),
~~~~~~~~~~~~
views.py
~~~~~~~~~~~~
if request.user.is_authenticated():
username = request.user.username
~~~~~~~~~~~~~~~~~~~
login.html
~
{% block content %}
{% if form.errors %}
<p class="error">Sorry, that‘s not a valid username or password</p>
{% endif %}
<form action="" method="post">
{% csrf_token %}
<label for="username">User name:</label>
<input type="text" name="username" value="" id="username">
<label for="password">Password:</label>
<input type="password" name="password" value="" id="password">
<input type="submit" value="login" />
<input type="hidden" name="next" value="/saltstack/" />
</form>
{% endblock %}