Opened 13 years ago
Closed 11 years ago
#16743 closed Bug (worksforme)
django-admin.py check for database config includind during help subcommand
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.3 |
Severity: | Normal | Keywords: | management django-admin.py manage.py |
Cc: | anssi.kaariainen@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If database settings define a dabatase engine not supported by the Python installation, it fails trying to show the "help" of any database related subcommand (i.e. sql*, syncdb, dumpdata, etc.).
In my case, i have 'postgresql_psycopg2' as 'ENGINE' value of the default database in settings.py (my production settings) and my python installation doesn't support postgresql. So, when i write:
$ python manage.py help dumpdata
i receive
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2
It should simply show the help text. This problems also happen with the tab autocomplete, if the system autocomplete knows how to autocomplete the django-admin.py subcommands, as is in my case in an Ubuntu 11.04 installation and Django installed via apt-get.
Attachments (1)
Change History (4)
comment:1 by , 13 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 11 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Progress has been made on delaying some imports generally. With current master, I cannot reproduce this issue.
I checked this, and the problem is that if you want to get the help text, you need to import the command class. The sql command classes use DEFAULT_DB_ALIAS from django.db and that is enough to get the ImproperlyConfigured Error. They uses the DEFAULT_DB_ALIAS as a default to --database option. And you don't have the help text available if you don't create the option. So, I don't see any trivial way to solve this. Allowing the import of DEFAULT_DB_ALIAS without an error and then being really careful about imports in commands would solve this, but that solution isn't ideal.