Django comes with a user authentication system. It handles user accounts,
groups, permissions and cookie-based user sessions. This section of the
documentation explains how the default implementation works out of the box, as
well as how to extend and customize it to
suit your project’s needs.
The Django authentication system handles both authentication and authorization.
Briefly, authentication verifies a user is who they claim to be, and
authorization determines what an authenticated user is allowed to do. Here the
term authentication is used to refer to both tasks.
- Permissions: Binary (yes/no) flags designating whether a user may perform
a certain task.
- Groups: A generic way of applying labels and permissions to more than one
- A configurable password hashing system
- Forms and view tools for logging in users, or restricting content
- A pluggable backend system
The authentication system in Django aims to be very generic and doesn’t provide
some features commonly found in web authentication systems. Solutions for some
of these common problems have been implemented in third-party packages:
Authentication support is bundled as a Django contrib module in
django.contrib.auth. By default, the required configuration is already
included in the
settings.py generated by
django-admin, these consist of two items listed in your
'django.contrib.auth'contains the core of the authentication framework,
and its default models.
'django.contrib.contenttypes'is the Django content type system, which allows permissions to be associated with
models you create.
and these items in your
sessions across requests.
users with requests using sessions.
manage.py migrate 为auth相关模型创建必要的数据表，并为已安装应用中定义的任何模型创建许可。
- Working with User objects
- Permissions and authorization
- Authentication in web requests
- Managing users in the admin