使用参数从django运行python manage.py命令

时间:2022-09-02 18:05:13

I have the command :

我有命令:

./manage.py dbbackup --clean --compress

provided by the django-dbbackup app which performs a backup of my PostgreSQL database to Amazon S3. I am trying to run this command inside a django celery task run daily.

由django-dbbackup应用程序提供,该应用程序将我的PostgreSQL数据库备份到Amazon S3。我想在每天运行的django芹菜任务中运行此命令。

When I run:

当我跑:

from django.core.management import call_command
call_command('dbbackup --clean --compress', interactive=False)

来自django.core.management import call_command call_command('dbbackup --clean --compress',interactive = False)

I am getting an exception because of the clean and compress arguments.

由于clean和compress参数,我得到一个异常。

Any ideas on how I can run this command?

关于如何运行此命令的任何想法?

1 个解决方案

#1


1  

I magically found that running:

我神奇地发现跑步:

call_command('dbbackup', clean=True, compress=True, interactive=False)

works perfectly.

#1


1  

I magically found that running:

我神奇地发现跑步:

call_command('dbbackup', clean=True, compress=True, interactive=False)

works perfectly.