poiuytrez
poiuytrez

Reputation: 22518

Running python manage.py command from django with arguments

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.

When I run:

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

Any ideas on how I can run this command?

Upvotes: 1

Views: 715

Answers (2)

Ankit Tiwari
Ankit Tiwari

Reputation: 1

You have to give arguments as separate strings:

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

Upvotes: 0

poiuytrez
poiuytrez

Reputation: 22518

I magically found that running:

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

works perfectly.

Upvotes: 1

Related Questions