运行时python manage.py test myapp2
,我收到此错误:
Creating test database for alias 'default'...
Problem installing fixture '... project folder .../mymainapp/fixtures/initial_data.yaml': Traceback (most recent call last):
File "... project folder .../venv/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 196, in handle
obj.save(using=using)
File "... project folder .../venv/lib/python2.7/site-packages/django/core/serializers/base.py", line 165, in save
models.Model.save_base(self.object, using=using, raw=True)
File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/base.py", line 524, in save_base
manager.using(using).filter(pk=pk_val).exists())):
File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/query.py", line 565, in exists
return self.query.has_results(using=self.db)
File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/sql/query.py", line 441, in has_results
return bool(compiler.execute_sql(SINGLE))
File "... project folder .../venv/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
cursor.execute(sql, params)
File "... project folder .../venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
return self.cursor.execute(query, args)
DatabaseError: Could not load myapp2.table2(pk=1): relation "myapp2_table2" does not exist
LINE 1: SELECT (1) AS "a" FROM "myapp2_table2" WHERE "myapp2...
^
但是,所有实际测试都运行良好,因此看来该夹具确实已成功安装。在运行南迁移时,我也可以成功安装这些装置。
即使它似乎没有任何影响,我能做些什么来修复这个错误?这似乎是在我手工制作南迁移之后才发生的。