如何加上「;说明“;对于Postgres DB中使用相应Django模型的列?
例如,在这个表中,我希望能够在Django ORM层添加“description”文本,并将其反映在数据库级别如何加上「;说明“;对于Postgres DB中使用相应Django模型的列?,django,postgresql,django-models,Django,Postgresql,Django Models,例如,在这个表中,我希望能够在Django ORM层添加“description”文本,并将其反映在数据库级别 test=# \d+ django_model Table "public.django_model" Column | Type | Modifiers | Description --------+---------+-----------+------------- i | integer | | j
test=# \d+ django_model
Table "public.django_model"
Column | Type | Modifiers | Description
--------+---------+-----------+-------------
i | integer | |
j | integer | |
Indexes:
"mi" btree (i) - Tablespace: "testspace"
"mj" btree (j)
Has OIDs: no
我想你做不到。这是请求。以“不会做”结束了6个ya 您仍然可以使用postgres
COMMENT
扩展名,例如:
t=# create table t (i int, t text);
CREATE TABLE
Time: 12.068 ms
t=# comment on column t.i is 'some description';
COMMENT
Time: 2.994 ms
t=# \d+ t
Table "postgres.t"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+------------------
i | integer | | | | plain | | some description
t | text | | | | extended | |
谢谢你的回复。是的,我找到了这些链接。但是,将信息从模型中分离出来是没有意义的,因为这可能会导致维护开销以及应用程序和数据库中存在的内容之间的潜在差异代码>也是可能的,并且需要
is
关键字。