---
title: "Using Django"
version: 2.0
locale: zh-hans
source: https://docs.djangoproject.com/zh-hans/2.0/topics/
canonical: https://djangodocs.dev/zh-hans/2.0/topics/
---
# Using Django

你需要知道的所有Django关键部分介绍：

- [How to install Django](/zh-hans/2.0/topics/install/)

  - [安装Python](/zh-hans/2.0/topics/install/#install-python)
  - [Install Apache and `mod_wsgi`](/zh-hans/2.0/topics/install/#install-apache-and-mod-wsgi)
  - [Get your database running](/zh-hans/2.0/topics/install/#get-your-database-running)
  - [移除任何老版本的Django](/zh-hans/2.0/topics/install/#remove-any-old-versions-of-django)
  - [Install the Django code](/zh-hans/2.0/topics/install/#install-the-django-code)
- [模型和数据库](/zh-hans/2.0/topics/db/)

  - [模型](/zh-hans/2.0/topics/db/models/)
  - [Making queries](/zh-hans/2.0/topics/db/queries/)
  - [聚合](/zh-hans/2.0/topics/db/aggregation/)
  - [Search](/zh-hans/2.0/topics/db/search/)
  - [Managers](/zh-hans/2.0/topics/db/managers/)
  - [Performing raw SQL queries](/zh-hans/2.0/topics/db/sql/)
  - [数据库事务](/zh-hans/2.0/topics/db/transactions/)
  - [Multiple databases](/zh-hans/2.0/topics/db/multi-db/)
  - [Tablespaces](/zh-hans/2.0/topics/db/tablespaces/)
  - [Database access optimization](/zh-hans/2.0/topics/db/optimization/)
  - [Database instrumentation](/zh-hans/2.0/topics/db/instrumentation/)
  - [Examples of model relationship API usage](/zh-hans/2.0/topics/db/examples/)
- [处理 HTTP 请求](/zh-hans/2.0/topics/http/)

  - [URL调度器](/zh-hans/2.0/topics/http/urls/)
  - [Writing views](/zh-hans/2.0/topics/http/views/)
  - [View decorators](/zh-hans/2.0/topics/http/decorators/)
  - [文件上传](/zh-hans/2.0/topics/http/file-uploads/)
  - [Django快捷函数](/zh-hans/2.0/topics/http/shortcuts/)
  - [通用视图](/zh-hans/2.0/topics/http/generic-views/)
  - [中间件](/zh-hans/2.0/topics/http/middleware/)
  - [How to use sessions](/zh-hans/2.0/topics/http/sessions/)
- [使用表单](/zh-hans/2.0/topics/forms/)

  - [HTML表单](/zh-hans/2.0/topics/forms/#html-forms)
  - [Django在表单中的角色](/zh-hans/2.0/topics/forms/#django-s-role-in-forms)
  - [Django 中的表单](/zh-hans/2.0/topics/forms/#forms-in-django)
  - [构建一张表单](/zh-hans/2.0/topics/forms/#building-a-form)
  - [详解Django `Form` 类](/zh-hans/2.0/topics/forms/#more-about-django-form-classes)
  - [使用表单模板](/zh-hans/2.0/topics/forms/#working-with-form-templates)
  - [更多相关主题](/zh-hans/2.0/topics/forms/#further-topics)
- [模板](/zh-hans/2.0/topics/templates/)

  - [模板引擎的支持](/zh-hans/2.0/topics/templates/#support-for-template-engines)
  - [The Django template language](/zh-hans/2.0/topics/templates/#the-django-template-language)
- [Class-based views](/zh-hans/2.0/topics/class-based-views/)

  - [Introduction to class-based views](/zh-hans/2.0/topics/class-based-views/intro/)
  - [Built-in class-based generic views](/zh-hans/2.0/topics/class-based-views/generic-display/)
  - [Form handling with class-based views](/zh-hans/2.0/topics/class-based-views/generic-editing/)
  - [Using mixins with class-based views](/zh-hans/2.0/topics/class-based-views/mixins/)
  - [Basic examples](/zh-hans/2.0/topics/class-based-views/#basic-examples)
  - [Simple usage in your URLconf](/zh-hans/2.0/topics/class-based-views/#simple-usage-in-your-urlconf)
  - [Subclassing generic views](/zh-hans/2.0/topics/class-based-views/#subclassing-generic-views)
- [Migrations](/zh-hans/2.0/topics/migrations/)

  - [The Commands](/zh-hans/2.0/topics/migrations/#the-commands)
  - [Backend Support](/zh-hans/2.0/topics/migrations/#backend-support)
  - [Workflow](/zh-hans/2.0/topics/migrations/#workflow)
  - [Dependencies](/zh-hans/2.0/topics/migrations/#dependencies)
  - [Migration files](/zh-hans/2.0/topics/migrations/#migration-files)
  - [Adding migrations to apps](/zh-hans/2.0/topics/migrations/#adding-migrations-to-apps)
  - [Historical models](/zh-hans/2.0/topics/migrations/#historical-models)
  - [Considerations when removing model fields](/zh-hans/2.0/topics/migrations/#considerations-when-removing-model-fields)
  - [Data Migrations](/zh-hans/2.0/topics/migrations/#data-migrations)
  - [Squashing migrations](/zh-hans/2.0/topics/migrations/#squashing-migrations)
  - [Serializing values](/zh-hans/2.0/topics/migrations/#serializing-values)
  - [Supporting multiple Django versions](/zh-hans/2.0/topics/migrations/#supporting-multiple-django-versions)
- [Managing files](/zh-hans/2.0/topics/files/)

  - [Using files in models](/zh-hans/2.0/topics/files/#using-files-in-models)
  - [The `File` object](/zh-hans/2.0/topics/files/#the-file-object)
  - [File storage](/zh-hans/2.0/topics/files/#file-storage)
- [Testing in Django](/zh-hans/2.0/topics/testing/)

  - [Writing and running tests](/zh-hans/2.0/topics/testing/overview/)
  - [Testing tools](/zh-hans/2.0/topics/testing/tools/)
  - [Advanced testing topics](/zh-hans/2.0/topics/testing/advanced/)
- [Django中的用户认证](/zh-hans/2.0/topics/auth/)

  - [概况](/zh-hans/2.0/topics/auth/#overview)
  - [安装](/zh-hans/2.0/topics/auth/#installation)
  - [Usage](/zh-hans/2.0/topics/auth/#usage)
- [Django's cache framework](/zh-hans/2.0/topics/cache/)

  - [Setting up the cache](/zh-hans/2.0/topics/cache/#setting-up-the-cache)
  - [The per-site cache](/zh-hans/2.0/topics/cache/#the-per-site-cache)
  - [The per-view cache](/zh-hans/2.0/topics/cache/#the-per-view-cache)
  - [Template fragment caching](/zh-hans/2.0/topics/cache/#template-fragment-caching)
  - [The low-level cache API](/zh-hans/2.0/topics/cache/#the-low-level-cache-api)
  - [下游缓存](/zh-hans/2.0/topics/cache/#downstream-caches)
  - [使用 `Vary` 标头](/zh-hans/2.0/topics/cache/#using-vary-headers)
  - [使用其他标头控制高速缓存](/zh-hans/2.0/topics/cache/#controlling-cache-using-other-headers)
  - [ \`\`MIDDLEWARE\`\`顺序](/zh-hans/2.0/topics/cache/#order-of-middleware)
- [Conditional View Processing](/zh-hans/2.0/topics/conditional-view-processing/)

  - [The `condition` decorator](/zh-hans/2.0/topics/conditional-view-processing/#the-condition-decorator)
  - [Shortcuts for only computing one value](/zh-hans/2.0/topics/conditional-view-processing/#shortcuts-for-only-computing-one-value)
  - [Using the decorators with other HTTP methods](/zh-hans/2.0/topics/conditional-view-processing/#using-the-decorators-with-other-http-methods)
  - [Comparison with middleware conditional processing](/zh-hans/2.0/topics/conditional-view-processing/#comparison-with-middleware-conditional-processing)
- [Cryptographic signing](/zh-hans/2.0/topics/signing/)

  - [Protecting the `SECRET_KEY`](/zh-hans/2.0/topics/signing/#protecting-the-secret-key)
  - [Using the low-level API](/zh-hans/2.0/topics/signing/#using-the-low-level-api)
- [Sending email](/zh-hans/2.0/topics/email/)

  - [快速上手](/zh-hans/2.0/topics/email/#quick-example)
  - [`send_mail()`](/zh-hans/2.0/topics/email/#send-mail)
  - [`send_mass_mail()`](/zh-hans/2.0/topics/email/#send-mass-mail)
  - [`mail_admins()`](/zh-hans/2.0/topics/email/#mail-admins)
  - [`mail_managers()`](/zh-hans/2.0/topics/email/#mail-managers)
  - [示例](/zh-hans/2.0/topics/email/#examples)
  - [Preventing header injection](/zh-hans/2.0/topics/email/#preventing-header-injection)
  - [The `EmailMessage` class](/zh-hans/2.0/topics/email/#the-emailmessage-class)
  - [Email backends](/zh-hans/2.0/topics/email/#email-backends)
  - [Configuring email for development](/zh-hans/2.0/topics/email/#configuring-email-for-development)
- [国际化和本地化](/zh-hans/2.0/topics/i18n/)

  - [概况](/zh-hans/2.0/topics/i18n/#overview)
  - [Definitions](/zh-hans/2.0/topics/i18n/#definitions)
- [日志](/zh-hans/2.0/topics/logging/)

  - [A quick logging primer](/zh-hans/2.0/topics/logging/#a-quick-logging-primer)
  - [Using logging](/zh-hans/2.0/topics/logging/#using-logging)
  - [配置日志](/zh-hans/2.0/topics/logging/#configuring-logging)
  - [Django's logging extensions](/zh-hans/2.0/topics/logging/#django-s-logging-extensions)
  - [Django's default logging configuration](/zh-hans/2.0/topics/logging/#django-s-default-logging-configuration)
- [Pagination](/zh-hans/2.0/topics/pagination/)

  - [例如](/zh-hans/2.0/topics/pagination/#example)
  - [Using `Paginator` in a view](/zh-hans/2.0/topics/pagination/#using-paginator-in-a-view)
  - [`Paginator` objects](/zh-hans/2.0/topics/pagination/#paginator-objects)
  - [`InvalidPage` exceptions](/zh-hans/2.0/topics/pagination/#invalidpage-exceptions)
  - [`Page` objects](/zh-hans/2.0/topics/pagination/#page-objects)
- [Security in Django](/zh-hans/2.0/topics/security/)

  - [Cross site scripting (XSS) protection](/zh-hans/2.0/topics/security/#cross-site-scripting-xss-protection)
  - [Cross site request forgery (CSRF) protection](/zh-hans/2.0/topics/security/#cross-site-request-forgery-csrf-protection)
  - [SQL injection protection](/zh-hans/2.0/topics/security/#sql-injection-protection)
  - [Clickjacking protection](/zh-hans/2.0/topics/security/#clickjacking-protection)
  - [SSL/HTTPS](/zh-hans/2.0/topics/security/#ssl-https)
  - [Host header validation](/zh-hans/2.0/topics/security/#host-header-validation)
  - [Session security](/zh-hans/2.0/topics/security/#session-security)
  - [User-uploaded content](/zh-hans/2.0/topics/security/#user-uploaded-content)
  - [Additional security topics](/zh-hans/2.0/topics/security/#additional-security-topics)
- [性能和优化](/zh-hans/2.0/topics/performance/)

  - [介绍](/zh-hans/2.0/topics/performance/#introduction)
  - [一般方法](/zh-hans/2.0/topics/performance/#general-approaches)
  - [Caching](/zh-hans/2.0/topics/performance/#caching)
  - [Understanding laziness](/zh-hans/2.0/topics/performance/#understanding-laziness)
  - [Databases](/zh-hans/2.0/topics/performance/#databases)
  - [HTTP performance](/zh-hans/2.0/topics/performance/#http-performance)
  - [Template performance](/zh-hans/2.0/topics/performance/#template-performance)
  - [Using different versions of available software](/zh-hans/2.0/topics/performance/#using-different-versions-of-available-software)
- [Serializing Django objects](/zh-hans/2.0/topics/serialization/)

  - [Serializing data](/zh-hans/2.0/topics/serialization/#serializing-data)
  - [Deserializing data](/zh-hans/2.0/topics/serialization/#deserializing-data)
  - [Serialization formats](/zh-hans/2.0/topics/serialization/#serialization-formats)
  - [Natural keys](/zh-hans/2.0/topics/serialization/#natural-keys)
- [Django settings](/zh-hans/2.0/topics/settings/)

  - [基础](/zh-hans/2.0/topics/settings/#the-basics)
  - [指定配置文件](/zh-hans/2.0/topics/settings/#designating-the-settings)
  - [默认配置](/zh-hans/2.0/topics/settings/#default-settings)
  - [在Python代码中使用settings](/zh-hans/2.0/topics/settings/#using-settings-in-python-code)
  - [运行时更改设置](/zh-hans/2.0/topics/settings/#altering-settings-at-runtime)
  - [安全](/zh-hans/2.0/topics/settings/#security)
  - [可用的配置项](/zh-hans/2.0/topics/settings/#available-settings)
  - [创建你自己的配置文件](/zh-hans/2.0/topics/settings/#creating-your-own-settings)
  - [Using settings without setting `DJANGO_SETTINGS_MODULE`](/zh-hans/2.0/topics/settings/#using-settings-without-setting-django-settings-module)
- [信号](/zh-hans/2.0/topics/signals/)

  - [Listening to signals](/zh-hans/2.0/topics/signals/#listening-to-signals)
  - [Defining and sending signals](/zh-hans/2.0/topics/signals/#defining-and-sending-signals)
  - [Disconnecting signals](/zh-hans/2.0/topics/signals/#disconnecting-signals)
- [系统检查框架](/zh-hans/2.0/topics/checks/)

  - [Writing your own checks](/zh-hans/2.0/topics/checks/#writing-your-own-checks)
- [External packages](/zh-hans/2.0/topics/external-packages/)

  - [Localflavor](/zh-hans/2.0/topics/external-packages/#localflavor)
  - [注释(Comments)](/zh-hans/2.0/topics/external-packages/#comments)
  - [Formtools](/zh-hans/2.0/topics/external-packages/#formtools)
