(Included in INSTALLED_APPS as a default)
Login page
You can use default django login handler.
<urls.py>
urlpatterns = patterns('',
...
(r'^login/$', 'django.contrib.auth.views.login')
<eof>
You need to make a template for login page.
<templates/registration/login.html>
<form methos='post' action='.'>
<label for='id_username'>Username : </label>
{{ form.username }}
<br>
<label for='id_password'>Password : </label>
{{ form.password }}
<br>
<input type='hidden' name='next' value='/'/>
<input type='submit' value='Login'/>
</form>
<eof>
User objects methods
- is_authenticated()
- get_full_name()
- email_user(subject, message, from_email=None)
- set_password(raw_password)
- check_password(raw_password)
Logout
<views.py>
from django.http import HttpResponseRedirect
from django.contrib.auth import logout
def logout_page(request):
logout(request)
return HttpResponseRedirect('/')
<eof>
<urls.py>
...
(r'^logout/$', logout_page),
...
<eof>
No comments:
Post a Comment