mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
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 <felisiak.mariusz@gmail.com> Co-authored-by: Nick Pope <nick@nickpope.me.uk>
This commit is contained in:
committed by
Mariusz Felisiak
parent
68ef274bc5
commit
78f163a4fb
@@ -40,6 +40,41 @@ in the future.
|
||||
.. _psycopg: https://www.psycopg.org/psycopg3/
|
||||
.. _psycopg library: https://pypi.org/project/psycopg/
|
||||
|
||||
Comments on columns and tables
|
||||
------------------------------
|
||||
|
||||
The new :attr:`Field.db_comment <django.db.models.Field.db_comment>` and
|
||||
:attr:`Meta.db_table_comment <django.db.models.Options.db_table_comment>`
|
||||
options allow creating comments on columns and tables, respectively. For
|
||||
example::
|
||||
|
||||
from django.db import models
|
||||
|
||||
class Question(models.Model):
|
||||
text = models.TextField(db_comment="Poll question")
|
||||
pub_date = models.DateTimeField(
|
||||
db_comment="Date and time when the question was published",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
db_table_comment = "Poll questions"
|
||||
|
||||
|
||||
class Answer(models.Model):
|
||||
question = models.ForeignKey(
|
||||
Question,
|
||||
on_delete=models.CASCADE,
|
||||
db_comment="Reference to a question"
|
||||
)
|
||||
answer = models.TextField(db_comment="Question answer")
|
||||
|
||||
class Meta:
|
||||
db_table_comment = "Question answers"
|
||||
|
||||
Also, the new :class:`~django.db.migrations.operations.AlterModelTableComment`
|
||||
operation allows changing table comments defined in the
|
||||
:attr:`Meta.db_table_comment <django.db.models.Options.db_table_comment>`.
|
||||
|
||||
Mitigation for the BREACH attack
|
||||
--------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user