vanadium23 / django-db-comments Goto Github PK
View Code? Open in Web Editor NEWMove your model's verbose name and help_text to database comments.
License: MIT License
Move your model's verbose name and help_text to database comments.
License: MIT License
This is a feature request: it would be possible to fetch the database comment not only from help_text
and from verbose_name
but also from the special __doc__
element attached to the column field? For instance, it would be great to do something like:
name = models.CharField(name='name', max_length=255, null=False)
"""
Name of the my awesome entity
"""
In this way we could fetch the help not only in the database, but also from the content assist (e.g., in PyCharm IDE) as well.
What do you think?
Need to deal with branch coverage...
Library seems to work on newer python & django version, we need to tune tox enviroment and Travis CI to check it.
pip install django-db-comments package.
python manage.py migrate
Got error for table "foo"."buzz_buzz"
django.db.utils.ProgrammingError: relation ""foo"."buzz_buzz"" does not exist
Traceback (most recent call last):
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 81, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation ""lis"."document_types"" does not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/core/management/init.py", line 423, in execute_from_command_line
utility.execute()
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/core/management/init.py", line 417, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/core/management/base.py", line 368, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/core/management/base.py", line 412, in execute
output = self.handle(*args, **options)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/core/management/base.py", line 93, in wrapped
res = handle_func(*args, **kwargs)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 284, in handle
emit_post_migrate_signal(
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/core/management/sql.py", line 37, in emit_post_migrate_signal
models.signals.post_migrate.send(
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 181, in send
return [(receiver, receiver(signal=self, sender=sender, **named)) for receiver in self._live_receivers(sender)]
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 181, in
return [(receiver, receiver(signal=self, sender=sender, **named)) for receiver in self._live_receivers(sender)]
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django_db_comments/db_comments.py", line 114, in copy_help_texts_to_database
add_column_comments_to_database(columns_comments, using)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django_db_comments/db_comments.py", line 57, in add_column_comments_to_database
cursor.execute(query, [comment])
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 96, in execute
return super().execute(sql, params)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 63, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 72, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 81, in _execute
return self.cursor.execute(sql, params)
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/db/utils.py", line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/nmaslov/PycharmProjects/lis-backend/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 81, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation ""lis"."document_types"" does not exist
When migration, it failed showing database table is missing, however, it's a proxy model, it should not have any tables. Could django-db-comments skip proxy/abstract models?
class Meta:
managed = False
# or
abstract = True
# or
proxy = True
$ docker-compose -f local.yml run django python manage.py migrate
Starting redis ... done
Starting mailhog ... done
Starting postgres ... done
PostgreSQL is available
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.9/site-packages/pgconnection/core.py", line 85, in execute
return super().execute(sql, args)
psycopg2.errors.UndefinedTable: relation "pghistory_aggregateevent" does not exist
If the file models.py is empty in your app directory, migrations fail with LookupError. If you delete the file, the error disappears.
python manage.py startapp newapp
Leave models.py empty and add 'newapp' to your INSTALLED_APPS.
python manage.py migrate
LookupError: No installed app with label 'newapp'.
I've missed that, travi-ci.org will now have some free plans and has changed site. CI will be dropped in 7 week, so we need to move repo to Github Action.
I am using MySQL,I want to do the same thing,I don't know how to change it.
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
Add uploading to PyPI via Github actions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.