Skip to content

Commit 7e1a692

Browse files
committed
add a help_text argument to Column
1 parent f2a8f0a commit 7e1a692

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

piccolo/columns/base.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class ColumnMeta:
123123
index: bool = False
124124
index_method: IndexMethod = IndexMethod.btree
125125
required: bool = False
126+
help_text: t.Optional[str] = None
126127

127128
# Used for representing the table in migrations and the playground.
128129
params: t.Dict[str, t.Any] = field(default_factory=dict)
@@ -244,6 +245,13 @@ class Column(Selectable):
244245
the user must provide this value. Example uses are in serialisers for
245246
API endpoints, and form fields.
246247
248+
:param help_text:
249+
This provides some context about what the column is being used for. For
250+
example, for a `Decimal` column called `value`, it could say
251+
'The units are millions of dollars'. The database doesn't use this
252+
value, but tools such as Piccolo Admin use it to show a tooltip in the
253+
GUI.
254+
247255
"""
248256

249257
value_type: t.Type = int
@@ -257,11 +265,12 @@ def __init__(
257265
index: bool = False,
258266
index_method: IndexMethod = IndexMethod.btree,
259267
required: bool = False,
268+
help_text: t.Optional[str] = None,
260269
**kwargs,
261270
) -> None:
262271
# Used for migrations.
263-
# We deliberately omit 'required' as it doesn't effect the actual
264-
# schema.
272+
# We deliberately omit 'required', and 'help_text' as they don't effect
273+
# the actual schema.
265274
kwargs.update(
266275
{
267276
"null": null,
@@ -288,6 +297,7 @@ def __init__(
288297
index_method=index_method,
289298
params=kwargs,
290299
required=required,
300+
help_text=help_text,
291301
)
292302

293303
self.alias: t.Optional[str] = None

0 commit comments

Comments
 (0)