2016-02-25

django.db.utils.ProgrammingError: relation "auth_group" does not exist

Djangoで、manage.py test をしたら、
django.db.utils.ProgrammingError: relation "auth_group" does not exist
とかいうエラーになって困った。開発環境のmacの上では起こらないんだけど、Ubuntu Server14.04で起こる。データベースはPostgreSQL。

何だろうっていろいろ調べたけど、ここが答えをくれた。 次のように言ってる人がいた。
Did you run python manage.py makemigrations appname first, where "appname" is the name of the app containing your custom user model inheriting from AbstractUser?
AbstractUserを定義しているappnameを指定して、makemigrationsをしたら解決。モデルがちゃんとつくられていなかったみたい。そういえば、DBをflushした後、これを実行するの忘れてたかも。

migrationのテーブルに不完全なデータしかない状態で、テスト用のテーブルを作成しようとしてエラーになっていたということだろうか。

0 件のコメント: