1

実行すると、おそらく FK に関連するエラーが表示されましたsyncdbMySQL 150ただし、 を繰り返し実行するsyncdbと、最終的には機能します (以下のトレース全体)。なぜこれが起こっているのですか?

    david-MacBook-Pro$ syncdb
    Creating tables ...
    Creating table jobs_company
    Creating table jobs_job
    Traceback (most recent call last):
      File "manage.py", line 14, in <module>
        execute_manager(settings)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
        utility.execute()
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
        output = self.handle(*args, **options)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
        return self.handle_noargs(**options)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 101, in handle_noargs
        cursor.execute(statement)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute
        return self.cursor.execute(sql, params)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute
        return self.cursor.execute(query, args)
      File "build/bdist.macosx-10.6-intel/egg/MySQLdb/cursors.py", line 174, in execute
      File "build/bdist.macosx-10.6-intel/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
    _mysql_exceptions.OperationalError: (1005, "Can't create table 'david542.#sql-2c3_57e' (errno: 150)")
    david-MacBook-Pro:$ syncdb
    Creating tables ...
    Creating table jobs_jobposition
    Creating table jobs_externaljob
    Creating table jobs_externalsite
    Creating table jobs_sitevisit
    Traceback (most recent call last):
      File "manage.py", line 14, in <module>
        execute_manager(settings)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
        utility.execute()
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
        output = self.handle(*args, **options)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
        return self.handle_noargs(**options)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 101, in handle_noargs
        cursor.execute(statement)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute
        return self.cursor.execute(sql, params)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute
        return self.cursor.execute(query, args)
      File "build/bdist.macosx-10.6-intel/egg/MySQLdb/cursors.py", line 174, in execute
      File "build/bdist.macosx-10.6-intel/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
    _mysql_exceptions.OperationalError: (1005, "Can't create table 'david542.#sql-2c3_57f' (errno: 150)")
    david-MacBook-Pro$ syncdb
    Creating tables ...
    Creating table jobs_application
    Traceback (most recent call last):
      File "manage.py", line 14, in <module>
        execute_manager(settings)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
        utility.execute()
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
        output = self.handle(*args, **options)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
        return self.handle_noargs(**options)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 101, in handle_noargs
        cursor.execute(statement)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute
        return self.cursor.execute(sql, params)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute
        return self.cursor.execute(query, args)
      File "build/bdist.macosx-10.6-intel/egg/MySQLdb/cursors.py", line 174, in execute
      File "build/bdist.macosx-10.6-intel/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
    _mysql_exceptions.OperationalError: (1005, "Can't create table 'david542.#sql-2c3_580' (errno: 150)")
    david-MacBook-Pro$ syncdb
    Creating tables ...
    Installing custom SQL ...
    Installing indexes ...
    No fixtures found.

そしてそれは動作しますか?

4

1 に答える 1

2

FKが作成されていないため、機能しています。生成されたSQLを分析して、エラーが発生している理由を確認し、必要に応じて並べ替えsettings.INSTALLED_APPSます。

于 2012-04-08T03:41:20.870 に答える