django-sql-dashboard icon indicating copy to clipboard operation
django-sql-dashboard copied to clipboard

Dynamically include documentation for tables and/or columns from Django model metadata

Open toolness opened this issue 4 years ago • 3 comments
trafficstars

Since a lot of the tables in a django-sql-dashboard ultimately come from Django models, I thought it would be helpful if the dashboard automatically surfaced the help_text for model fields, and perhaps even the docstring for models themselves, when applicable. This way someone new to the database schema could easily be onboarded.

One easy way to do this without disrupting the current design would be to just add a title attribute to column names that's set to the help_text of the relevant column. However, this would only surface on devices with mice, and wouldn't be accessible to keyboard-only users or screen readers. A more accessible alternative might be to add an information widget (perhaps the unicode character ℹ or an icon of an "i" with a circle around it) that displayed the tooltip on click or enter/space keypress.

toolness avatar May 20 '21 11:05 toolness

This is a really interesting idea. The current database documentation (recently much improved) looks like this:

SQL_Dashboard

simonw avatar May 24 '21 19:05 simonw

I've been thinking about ways of adding optional extra metadata to tables and columns - maybe with some kind of YAML configuration - but I have to admit I hadn't thought to use the existing Django metadata for that!

simonw avatar May 24 '21 21:05 simonw

An interesting opportunity here is that PostgreSQL gives us enough information in cursor.description to tell which table and column the results in an arbitrary query came from - so no matter the query, if a column comes from a specific table we can add extra contextual information to it.

simonw avatar May 25 '21 00:05 simonw