ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Django框架中的用户认证的实现

Django框架中的用户认证的实现

原创 Linux操作系统 作者:jieforest 时间:2012-12-09 11:19:42 0 删除 编辑
Django comes with a user authentication system. It handles user accounts, groups, permissions and cookie-based user sessions. This document explains how things work.

Overview
The auth system consists of:

1. Users
2. Permissions: Binary (yes/no) flags designating whether a user may perform. a certain task.
3. Groups: A generic way of applying labels and permissions to more than one user.

Installation
Authentication support is bundled as a Django application in django.contrib.auth. To install it, do the following:

1. Put 'django.contrib.auth' and 'django.contrib.contenttypes' in your INSTALLED_APPS setting. (The Permission model indjango.contrib.auth depends on django.contrib.contenttypes.)
2. Run the command manage.py syncdb.

Note that the default settings.py file created by django-admin.py startproject includes 'django.contrib.auth' and'django.contrib.contenttypes' in INSTALLED_APPS for convenience. If your INSTALLED_APPS already contains these apps, feel free to run manage.py syncdb again; you can run that command as many times as you’d like, and each time it’ll only install what’s needed.

The syncdb command creates the necessary database tables, creates permission objects for all installed apps that need ‘em, and prompts you to create a superuser account the first time you run it.

Once you’ve taken those steps, that’s it.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/301743/viewspace-750802/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-04-23

  • 博文量
    441
  • 访问量
    602322