From 78f163a4fb3937aca2e71786fbdd51a0ef39629e Mon Sep 17 00:00:00 2001 From: kimsoungryoul Date: Sun, 16 Oct 2022 14:59:39 +0900 Subject: Fixed #18468 -- Added support for comments on columns and tables. Thanks Jared Chung, Tom Carrick, David Smith, Nick Pope, and Mariusz Felisiak for reviews. Co-authored-by: Mariusz Felisiak Co-authored-by: Nick Pope --- docs/ref/models/fields.txt | 15 +++++++++++++++ docs/ref/models/options.txt | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'docs/ref/models') diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 0afddc14a8..d460e81ef4 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -325,6 +325,21 @@ characters that aren't allowed in Python variable names -- notably, the hyphen -- that's OK. Django quotes column and table names behind the scenes. +``db_comment`` +-------------- + +.. versionadded:: 4.2 + +.. attribute:: Field.db_comment + +The comment on the database column to use for this field. It is useful for +documenting fields for individuals with direct database access who may not be +looking at your Django code. For example:: + + pub_date = models.DateTimeField( + db_comment="Date and time when the article was published", + ) + ``db_index`` ------------ diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt index a1629168af..a882fcb05a 100644 --- a/docs/ref/models/options.txt +++ b/docs/ref/models/options.txt @@ -91,6 +91,24 @@ Django quotes column and table names behind the scenes. backends; except for Oracle, however, the quotes have no effect. See the :ref:`Oracle notes ` for more details. +``db_table_comment`` +-------------------- + +.. versionadded:: 4.2 + +.. attribute:: Options.db_table_comment + +The comment on the database table to use for this model. It is useful for +documenting database tables for individuals with direct database access who may +not be looking at your Django code. For example:: + + class Answer(models.Model): + question = models.ForeignKey(Question, on_delete=models.CASCADE) + answer = models.TextField() + + class Meta: + db_table_comment = "Question answers" + ``db_tablespace`` ----------------- -- cgit v1.3