Skip to content

djangodocs

Django 2.0
  • 6.1 current
  • 6.0
  • 5.2 LTS
  • 5.1 unsupported
  • 5.0 unsupported
  • 4.2 unsupported
  • 4.1 unsupported
  • 4.0 unsupported
  • 3.2 unsupported
  • 3.1 unsupported
  • 3.0 unsupported
  • 2.2 unsupported
  • 2.1 unsupported
  • 2.0 unsupported
简体中文
  • English
  • 简体中文
  • Français
  • 日本語
  • Bahasa Indonesia
  • Português (Brasil)
  • 한국어
  • Español
  • Ελληνικά
  • Polski
Documentation contents
  • Django 文档
  • 开始
  • Using Django
    • How to install Django
    • 模型和数据库
      • 模型
      • Making queries
      • 聚合
      • Search
      • Managers
      • Performing raw SQL queries
      • 数据库事务
      • Multiple databases
      • Tablespaces
      • Database access optimization
      • Database instrumentation
      • Examples of model relationship API usage
        • Many-to-many relationships
        • Many-to-one relationships
        • One-to-one relationships
    • 处理 HTTP 请求
    • 使用表单
    • 模板
    • Class-based views
    • Migrations
    • Managing files
    • Testing in Django
    • Django中的用户认证
    • Django's cache framework
    • Conditional View Processing
    • Cryptographic signing
    • Sending email
    • 国际化和本地化
    • 日志
    • Pagination
    • Security in Django
    • 性能和优化
    • Serializing Django objects
    • Django settings
    • 信号
    • 系统检查框架
    • External packages
  • "How-to" guides
  • Django FAQ
  • API Reference
  • 元文件和杂记
  • 术语
  • Release notes
  • Django internals
Django 2.0 is no longer supported. It receives no security fixes. Use it for reference only. Latest release
Chinese (Simplified) translation. Untranslated passages appear in English. 26.5% Help translate
  1. Django 2.0
  2. Using Django
  3. 模型和数据库

Examples of model relationship API usageLink to this heading#

  • Many-to-many relationships
  • Many-to-one relationships
  • One-to-one relationships
View as Markdown Edit this page on GitHub Official version
PreviousDatabase instrumentation NextMany-to-many relationships

An unofficial rendering of the Django documentation.

Not affiliated with or endorsed by the Django Software Foundation. The documentation is copyright © Django Software Foundation and individual contributors, and is used under the BSD 3-Clause licence. “Django” is a trademark of the Django Software Foundation.

This translation is the work of the Django i18n community, not of this site. Read the official documentation at docs.djangoproject.com.

👋 Jason Cartwright