I totally missed that django now supports database comments on model fields. That’s great! My next thought was that it would be really nice if help_text could be put into the db_comment field in some sort of automatic way. We always complete the help_text field, so it’d be a huge win to sync it to the DB somehow.
For example, we have this field:
cluster_start = models.ForeignKey(
OpinionCluster,
help_text="The starting cluster for the visualization",
)
And I guess what we’re going to wind up doing is something like:
cluster_start_help = "The starting cluster for the visualization",
cluster_start = models.ForeignKey(
OpinionCluster,
help_text=cluster_start_help,
db_comment=cluster_start_help,
)
And that’s OK, I suppose. But it’d be really nice to just have it sync.
In the issue that landed the db_comment attribute, somebody mentioned a setting for this, ENABLE_DB_COMMENT_WITH_HELP_TEXT, but doing it via a setting wasn’t popular and it died on the vine. In the PR that landed it, somebody suggested using verbose_name for this, but, “verbose_names are for users and db_comments are for DBAs.”
I agree with all of this, but it does feel redundant to me to have to describe a field twice.
I wonder if there’s a way to do something like:
cluster_start = models.ForeignKey(
OpinionCluster,
help_text="The starting cluster for the visualization",
db_comment=True,
)
If that could work automatically, that’d be really nice. I’m curious what other folks think.
Have a great day and happy holidays,
Mike