Account

Path

  • /accounts/login/
  • /accounts/logout/
  • /accounts/register/ (Not use)

Code

class account.views
login(request)

If GET, it will return a page to login. If POST, it need username and password. If the username and password is correct, it will redirect to home, else it will return the login page with a warning.

Note

If already login, it will return the ‘has_login.html’

logout(request)

It will logout the account and redirect to the login page.

class account.models.Profile

It add sex, birthday and image to django’s default user django.contrib.auth.models.User using OneToOneField.

Template

login.html

failed

If True, it will add a ‘wrong username or password’ message in the page.