Opened 5 years ago

Closed 13 months ago

#18468 closed New feature (duplicate)

Add the ability to define comments in table / columns

Reported by: Marc Rechté Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords:
Cc: niwi@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



That would be nice if it was possible to include comment on table / columns at creation time with the syncdb option.

There could be a new Model Meta option like:

comment = 'This table is for storing blabla"

And a new Field option like:

comment = 'This field is for ...'

Thanks a lot

Change History (7)

comment:1 Changed 5 years ago by Andrei Antoukh

Cc: niwi@… added
Has patch: set

I've implemented initial implementatio for postgresql_psycopg2 backend:

Is only implemented the table comment sql.

If accepted as a new feature, would be nice to make design decisions. Today I put the comment for table in class "Meta", another option is to use the first line of the model docstrings.

For fields, is more simple, just add an optional parameter "comment" at the Field.

Version 0, edited 5 years ago by Andrei Antoukh (next)

comment:2 Changed 5 years ago by Aymeric Augustin

Resolution: duplicate
Status: newclosed

This is a duplicate of #13867, which lingered in DDN for two years until I wontfix'd it.

The only argument I've seen is "it'd be nice if...". But I'm against adding features to Django just because we can; there must be a use case.

Could you start a thread on the mailing-list, as recommended in the contributing guide, to see if there is support for this idea?

If there's a good explanation of why you need this, I can reconsider my decision.

comment:3 Changed 5 years ago by Andrei Antoukh

I understand your opinion! In any case, I'll write an email to the list which I think is useful.

comment:4 Changed 5 years ago by Marc Rechté

I assume that most databases have comment on fields / tables feature not just because it is nice. Accessing Django created tables from another tool (for instance pgAdmin) would just make the system more productive. Personally I never create SQL tables without proper comments in the database itself.

comment:5 Changed 5 years ago by Luke Plant

The reasons given on #13867 still stand — Django is not aiming to provide a wrapper for every SQL feature. For example, it also doesn't provide an easy way to create stored procedures, functions or views, but you can always execute the SQL manually to add these, or could add some additional Python code that executed the SQL — for example using a South migration — if you want to ensure it always happens.

In addition, if the audience of these comments is people administering the database without reading the Python source code, it doesn't make sense for these comments to be taking up space in the Python code, which has its own way of adding comments (docstrings and comment lines), which are targeted at programmers not DB admins.

comment:6 Changed 13 months ago by Marc Rechté

Resolution: duplicate
Status: closednew

Now that migration is built in Django, which can be used to create and administer the database, I again request this feature to be added. Thanks.

comment:7 Changed 13 months ago by Tim Graham

Resolution: duplicate
Status: newclosed
Summary: Define COMMENT in table / colomnsAdd the ability to define comments in table / columns
Type: UncategorizedNew feature

The correct way to reopen a ticket closed as "wontfix" is to start a discussion on the DevelopersMailingList. If there is consensus there to add the feature, then we reopen the ticket.

Note: See TracTickets for help on using tickets.
Back to Top