1

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).

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

However the dumpdata output is empty:

(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
[]

For the other apps dumpdata is working properly:

(venv)[root@dl380p1 team112]# ./manage.py dumpdata reports | wc -c
239811

I don't want to use the entire table dumps (pgdump) due to obvious reasons. Hope to find right solution here.

4

2 回答 2

4

我有同样的问题,它与数据库路由器有关。只需确保路由器正确处理该allow_migrate方法(默认情况下,其中一个路由器应返回True或类似 True 的值)。在此处查看更多示例:Django 多个数据库示例

于 2014-10-21T10:03:38.320 回答
0

我没有多个数据库,但在转储时我仍然得到空的固定装置。

我必须在我的应用程序中添加一个单独的空 models.py 才能转储数据。

于 2022-01-28T05:06:35.623 回答