例如,在本表中,我希望能够在Django ORM层添加“描述”文本并将其反映在数据库级别。
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
答案 0 :(得分:1)
我想你不能这样做。这是https://code.djangoproject.com/ticket/13867请求。关闭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 | |