从postgres db生成模型类时,inspectdb命令崩溃

时间:2018-03-26 11:54:07

标签: python django django-models django-orm

执行inspectdb时的

> modelys.py,我收到以下错误。 我搜索了解决方案,但我找不到任何东西。更多我不知道这个错误到底意味着什么。

(gathiApiVirtualEnv) G:\GathiCatalog\dev\gathiApi\gathi_api>python manage.py inspectdb >models.py
Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "G:\GathiCatalog\dev\gathiApi\gathiApiVirtualEnv\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "G:\GathiCatalog\dev\gathiApi\gathiApiVirtualEnv\lib\site-packages\django\core\management\__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "G:\GathiCatalog\dev\gathiApi\gathiApiVirtualEnv\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "G:\GathiCatalog\dev\gathiApi\gathiApiVirtualEnv\lib\site-packages\django\core\management\base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "G:\GathiCatalog\dev\gathiApi\gathiApiVirtualEnv\lib\site-packages\django\core\management\commands\inspectdb.py", line 28, in handle
    for line in self.handle_inspection(options):
  File "G:\GathiCatalog\dev\gathiApi\gathiApiVirtualEnv\lib\site-packages\django\core\management\commands\inspectdb.py", line 163, in handle_inspection
    for meta_line in self.get_meta(table_name, constraints, column_to_field_name):
  File "G:\GathiCatalog\dev\gathiApi\gathiApiVirtualEnv\lib\site-packages\django\core\management\commands\inspectdb.py", line 273, in get_meta
    tup = '(' + ', '.join("'%s'" % column_to_field_name[c] for c in columns) + ')'
  File "G:\GathiCatalog\dev\gathiApi\gathiApiVirtualEnv\lib\site-packages\django\core\management\commands\inspectdb.py", line 273, in <genexpr>
    tup = '(' + ', '.join("'%s'" % column_to_field_name[c] for c in columns) + ')'
KeyError: 'prj_id'

0 个答案:

没有答案