Django dumpdata输出为空 [英] Django dumpdata output is empty
问题描述
我们有一个带有PostgreSQL 9.3后端的Django 1.4.5项目。不幸的是,当我们尝试为其中一个应用程序(称为 sddb
)创建固定装置时遇到了问题。
we have a Django 1.4.5 project with a PostgreSQL 9.3 backend. Unfortunately we are facing the problems when attempting to create fixtures for one of the apps (which is called sddb
).
数据库中充满了属于 sddb
应用程序的对象:
The database is full of objects that belong to sddb
app:
(venv)[root@dl380p1 team112]# ./manage.py shell
>>> from sddb.models.media import Metadata
>>> len(Metadata.objects.all())
22916
但是 dumpdata
输出为空:
(venv)[root@dl380p1 team112]# ./manage.py dumpdata sddb
[]
数据库的显式指向(提到此处)没有帮助:
Explicit pointing of database (mentioned here) didn't help:
(venv)[root@dl380p1 team112]# ./manage.py dumpdata --database=project_test sddb
[]
对于其他应用程序 dumpdata
正常运行:
For the other apps dumpdata
is working properly:
(venv)[root@dl380p1 team112]# ./manage.py dumpdata reports | wc -c
239811
我不想使用整个表转储( pgdump
),原因显而易见。希望在这里找到正确的解决方案。
I don't want to use the entire table dumps (pgdump
) due to obvious reasons. Hope to find right solution here.
推荐答案
我遇到了同样的问题,并且与DB路由器有关。只需确保路由器正确处理 allow_migrate
方法即可(其中一个路由器应返回 True
或类似True的值)默认)。
在此处查看更多示例: Django多个数据库例子
I had the same problem and it was related to DB routers. Just make sure that a router processes correctly the allow_migrate
method (one of routers should return True
or True-like value by default).
See more examples here: Django Multiple databases Examples
这篇关于Django dumpdata输出为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!