【发布时间】:2018-11-14 19:28:31
【问题描述】:
我正在调用一个名为 People 的模型并执行
People.objects.create(first='foo', last='bar', bio='test')
此模型使用db_table='"people"."background"'
当我运行测试时,执行 People.objects.first() 会找到一些东西,但是执行像 SELECT * from people.background 这样的原始查询却什么也没有。这是为什么呢?
【问题讨论】:
-
测试在不同的数据库上运行,通常带有
test_前缀 iirc。 -
@WillemVanOnsem 我知道这一点。表
people.background已正确创建,检查模型的描述确实表明db_table 应该是people.background。据我所知,它应该连接到正确的数据库,但我找不到创建的数据......
标签: django unit-testing django-models