django系列1 - User Authentication(翻译+整理)
来源:互联网 发布:杭州亚信软件 编辑:程序博客网 时间:2024/06/05 08:09
1.总览
包括:
- user:
- permissions:二进制的标志,标明是否有权限执行某操作
- groups:给多个用户打标签和设置权限
2.安装&激活
authentication的支持是作为一个django application,绑定在django.contrib.auth模块中。安装步骤:
- 在settings.py中的INSTALLED_APPS中,添加django.contrib.auth和django.contrib.contenttypes。
- run: manage.py syncdb
3.类Class
(1)User
class models.User
Fields
- username:required
- first_name:optional
- last_name:
- email:
- password:
- is_staff:
- is_active:
- is_superuser:
- last_login:
- date_joined:
Methods
- is_anonymous():
- is_authenticated():
- get_full_name():
- set_password():
- check_password():
- set_unusable_password():
- has_usable_password():
- get_group_permissions():
- get_all_permissions():
- has_perm():
- has_perms():
- has_module_perms():
- email_user():
- get_profile():
(2)UserManager
class models.UserManager
Methods
- create_user():
- make_random_password():
(3)AnonymousUser
class models.AnonymousUser
4.基本用法
(1)创建用户
(2)修改密码
(3)创建超级用户
(4)存储用户的附加信息profile
- 创建自定义类:必须定义一个field去关联User,再定义附加的field:
- 在settings.py中增加配置:
- 获取profile:get_profile()
- django系列1 - User Authentication(翻译+整理)
- User Authentication in Django
- User authentication in Django 阅读批注
- 基于How To Tango With Django 1.9的重新实践(9)——User Authentication
- 五 Django 1.5.4 User Authentication 用户认证
- Django中对于Authentication用户User的扩展
- User authentication
- Django REST framework-教程04-Authentication and Permissions原创翻译
- 基于How To Tango With Django 1.9的重新实践(11)——User Authentication with {#chapter-redux}
- centos7解决django.db.utils.OperationalError: FATAL: Peer authentication failed for user "postgres"
- Chapter 2 User Authentication, Authorization, and Security(1):选择Windows和SQL 身份验证
- ESG User Authentication
- django User
- Customizing authentication in Django
- 创建Predix UAA(User Account and Authentication)
- Django笔记整理1
- 翻译 Netty 4 开发人员指导-User Guide(1)
- Jaas Authentication文档翻译
- android开发实战系列(04)-- 创建第一个Android项目
- Project Explorer (1) -- "Build Project" 和 "Clean Project"
- 【iOS开发】---- 二维码
- [APUE读书笔记] 有关exit 和_exit区别的比较
- android开发实战系列(05)-- 运行你的应用
- django系列1 - User Authentication(翻译+整理)
- hdu - 4442 - Physical Examination
- java 枚举
- LZW算法PHP实现方法
- JS实现抛物线运动
- javaWeb_07-用refresh控制浏览器定时刷新
- SQL优化---活动监视器
- 博通首款LTE移动芯片将量产 挑战高通统治地位
- android开发实战系列(06)-- 创建一个简单的用户界面