Django dumpdata output is empty

↘锁芯ラ 提交于 2020-01-16 18:39:06

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/26252228/django-dumpdata-output-is-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!