私はこれについてかなりの記事を見てきましたが、これまでのところ私は役に立たなかった。私は、仕事のdjangoアプリケーションを持っていて、私はsqliteからpostgresqlデータベースに行きたいと思っています。そのために、私はdjangogirlsのチュートリアルに従っています。何かエラーが発生するまで、素晴らしいです。django sqlite to postgresql移行時のProgrammingError
開発用に私のPCにpostgresqlをダウンロードしたところ、うまく動作しているpsycopg2をダウンロードしてインストールしました。私はsettings.py DB設定を変更しました。私はpostgresに移行したいところです。
チュートリアルで言うところの "python manage.py migrate"を実行するのは、私にとってはうまくいきませんでした。なぜなら、それは空のアプリケーションか何かであると考えられていて、すでにマイグレーションとモデルが関連付けられているからです。
私が実行している
python manage.py makemigrations
python manage.py migrate
は、トリックを行うだろうと読んで、私は私のカスタムモデルに問題がありました。私はその後、私は
python manage.py makemigrations
python manage.py migrate --fake
コメント解除を実行し、この問題のモデルを使用するすべてのコードをコメントアウトし、私が試したが、今私は同じエラーを取得しています
python manage.py migrate
を実行することができることを読んで私のカスタムモデルとしてではなく、contenttypesアプリのために。
トレースバックはこれです:
:( "ラ・関係 'たdjango_content_type' n'existeのPASは" = "関係 'たdjango_content_type' が存在しません")
Operations to perform:
Apply all migrations: auth, contenttypes, sessions, admin
Running migrations:
No migrations to apply.
Traceback (most recent call last):
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: ERREUR: la relation « django_content_type » n'existe pas
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\contrib\contenttypes\models.py", line 67, in get_for_model
ct = self.get(app_label=opts.app_label, model=opts.model_name)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\models\manager.py", line 122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\models\query.py", line 381, in get
num = len(clone)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\models\query.py", line 240, in __len__
self._fetch_all()
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\models\query.py", line 1074, in _fetch_all
self._result_cache = list(self.iterator())
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\models\query.py", line 52, in __iter__
results = compiler.execute_sql()
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\models\sql\compiler.py", line 848, in execute_sql
cursor.execute(sql, params)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: ERREUR: la relation « django_content_type » n'existe pas
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...
^
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\core\management\__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\core\management\base.py", line 399, in execute
output = self.handle(*args, **options)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\core\management\commands\migrate.py", line 204, in handle
emit_post_migrate_signal(self.verbosity, self.interactive, connection.alias)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\core\management\sql.py", line 50, in emit_post_migrate_signal
using=db)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\dispatch\dispatcher.py", line 192, in send
response = receiver(signal=self, sender=sender, **named)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\contrib\auth\management\__init__.py", line 85, in create_permissions
ctype = ContentType.objects.db_manager(using).get_for_model(klass)
File "C:\Users\gbastien1\Envs\django-carte\lib\site-packages\django\contrib\contenttypes\models.py", line 80, in get_for_model
"Error creating new content types. Please make sure contenttypes "
RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.
私の移行は次のようになり
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
sessions
[X] 0001_initial
私は非常に多くのことを試みたので、この問題の解決方法はわかりません。データベースとデプロイメントは私の強みではありません。誰かが私にこれを理解してもらえますか?私は自分のアプリケーションが働いていたし、私のsqliteのファイルとすべての私の移行を削除してやり直す一部に私のすべての変更を元に戻す試みた
EDIT は、私はすべてのコードをコメントアウトし、すべての私のPYC(Pythonのキャッシュ)ファイルを削除しましたEcoleモデルに関連して再度マイグレートしても、同じエラーが表示されます。(
sqliteからデータを保持しますか?そして、 'python manage.py contenttypeの移行'は何をしますか? –
私はsqliteから自分のデータを失っても構いません。そのコマンドは上記と同じエラーを出力します:/ –
答えに新しい情報を追加するのではなく、質問を編集できます。 – marcanuy