Skip to main content

add database table column comments

Project description

django_database_colum_comment

auto add comment for columns of MySQL or PostgreSQL

the property verbose_name or help_text of the django model will be used as comment for columns

Database Supported

  • MySQL
  • PostgreSQL

How to use

the model, you need to notice that the order verbose_name is at the first, then help_text

name = models.CharField(max_length=200, verbose_name="名称", blank=True, default=None)
age = models.SmallIntegerField(help_text="年龄", blank=True, default=None)

then, install the package

pip install addcomments

in settings.py add app

INSTALLED_APPS += [
    'addcomments',
]

next, type command

python manage.py addcolumncomments

finally, the info will be printed, all the models created will be processed

## MySQL 
-- FOR test_student.name 
        ALTER TABLE test_student
        MODIFY COLUMN `name` varchar(200) COLLATE utf8mb4_bin NOT NULL  COMMENT '名称'
-- FOR test_student.age 
        ALTER TABLE test_student
        MODIFY COLUMN `age` smallint(6) NOT NULL  COMMENT '年龄'

## PostgreSQL
-- FOR test_student.name 
        COMMENT ON COLUMN test_student.name IS '名称'
-- FOR test_student.age 
        COMMENT ON COLUMN test_student.age IS '年龄'

If any bug

you can fix by yourself or commit your issue here, I will fix it

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

addcomments-1.0.0.tar.gz (3.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page