【发布时间】:2011-09-07 14:26:36
【问题描述】:
尝试在 PostgreSQL 后端为项目运行 DJ 测试时,我遇到了一个非常烦人的问题。它开始运行测试,当第一次刷新数据库时,它会失败并出现一个奇怪的错误:
..Error: Database dbname couldn't be flushed. Possible reasons:
* The database isn't running or isn't configured correctly.
* At least one of the expected database tables doesn't exist.
* The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: cannot TRUNCATE "table_name" because it has pending trigger events
如果我通过 pgAdmin 运行 sqlflush 的输出,它运行得很好。
欢迎对可能的原因提出任何想法。
更新:
好的,看起来这实际上不是 Django 的问题,而是与 djangosanetesting 中的测试运行程序有关。使用默认的 DJ 测试运行器或 django-nose 测试运行器它可以工作。
【问题讨论】:
标签: python database django postgresql testing