我正在使用call_command來啓動一個datadump,我想排除多個應用程序,所以如果我不使用call_command,我會這樣做,就像django文檔告訴做的那樣:使用call_command排除django dumpdata中的多個應用程序
python manage.py dumpdata --format json -e app1 -e app2
但call_command我不知道我應該怎麼稱呼它:
from django.core.management import call_command
call_command("dumpdata", format="json", ?)
什麼不工作:
call_command("dumpdata", format="json", exclude="app1")
call_command("dumpdata", format="json", exclude="app1 app2")
# CommandError: No installed app with label 'a'.
call_command("dumpdata", format="json", e="app1")
call_command("dumpdata", format="json", e="app1 app2")
# Does not fail but does not exclude anything either
call_command("dumpdata", format="json", e="app1", e="app2")
# SyntaxError: keyword argument repeated
使用call_command甚至可以從dumpdata中排除某些內容嗎?
在此先感謝。