From 8eae094638acf802c8047b341d126d94bc9b45a3 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sun, 5 Aug 2018 22:30:44 -0400 Subject: Generalized check constraint docs for other constraints. --- docs/ref/models/check-constraints.txt | 46 ----------------------------------- docs/ref/models/constraints.txt | 45 ++++++++++++++++++++++++++++++++++ docs/ref/models/index.txt | 2 +- docs/ref/models/options.txt | 4 +-- 4 files changed, 48 insertions(+), 49 deletions(-) delete mode 100644 docs/ref/models/check-constraints.txt create mode 100644 docs/ref/models/constraints.txt (limited to 'docs/ref/models') diff --git a/docs/ref/models/check-constraints.txt b/docs/ref/models/check-constraints.txt deleted file mode 100644 index 06ddd26b54..0000000000 --- a/docs/ref/models/check-constraints.txt +++ /dev/null @@ -1,46 +0,0 @@ -=========================== -Check constraints reference -=========================== - -.. module:: django.db.models.constraints - -.. currentmodule:: django.db.models - -.. versionadded:: 2.2 - -The ``CheckConstraint`` class creates database check constraints. They are -added in the model :attr:`Meta.constraints -` option. This document -explains the API references of :class:`CheckConstraint`. - -.. admonition:: Referencing built-in constraints - - Constraints are defined in ``django.db.models.constraints``, but for - convenience they're imported into :mod:`django.db.models`. The standard - convention is to use ``from django.db import models`` and refer to the - constraints as ``models.CheckConstraint``. - -``CheckConstraint`` options -=========================== - -.. class:: CheckConstraint(*, check, name) - - Creates a check constraint in the database. - -``check`` ---------- - -.. attribute:: CheckConstraint.check - -A :class:`Q` object that specifies the check you want the constraint to -enforce. - -For example ``CheckConstraint(check=Q(age__gte=18), name='age_gte_18')`` -ensures the age field is never less than 18. - -``name`` --------- - -.. attribute:: CheckConstraint.name - -The name of the constraint. diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt new file mode 100644 index 0000000000..9e24a1cad8 --- /dev/null +++ b/docs/ref/models/constraints.txt @@ -0,0 +1,45 @@ +===================== +Constraints reference +===================== + +.. module:: django.db.models.constraints + +.. currentmodule:: django.db.models + +.. versionadded:: 2.2 + +The classes defined in this module create database constraints. They are added +in the model :attr:`Meta.constraints ` +option. + +.. admonition:: Referencing built-in constraints + + Constraints are defined in ``django.db.models.constraints``, but for + convenience they're imported into :mod:`django.db.models`. The standard + convention is to use ``from django.db import models`` and refer to the + constraints as ``models.Constraint``. + +``CheckConstraint`` +=================== + +.. class:: CheckConstraint(*, check, name) + + Creates a check constraint in the database. + +``check`` +--------- + +.. attribute:: CheckConstraint.check + +A :class:`Q` object that specifies the check you want the constraint to +enforce. + +For example ``CheckConstraint(check=Q(age__gte=18), name='age_gte_18')`` +ensures the age field is never less than 18. + +``name`` +-------- + +.. attribute:: CheckConstraint.name + +The name of the constraint. diff --git a/docs/ref/models/index.txt b/docs/ref/models/index.txt index c3aa5a718a..e48e138578 100644 --- a/docs/ref/models/index.txt +++ b/docs/ref/models/index.txt @@ -9,7 +9,7 @@ Model API reference. For introductory material, see :doc:`/topics/db/models`. fields indexes - check-constraints + constraints meta relations class diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt index 6c098a8f56..4aedd4b92a 100644 --- a/docs/ref/models/options.txt +++ b/docs/ref/models/options.txt @@ -459,8 +459,8 @@ Django quotes column and table names behind the scenes. .. versionadded:: 2.2 - A list of :doc:`constraints ` that you want - to define on the model:: + A list of :doc:`constraints ` that you want to + define on the model:: from django.db import models -- cgit v1.3