I'm working with a PyQt application which uses Django to deliver it's content to desktop users.
In the latest update we have stale content types stored in the database by Django and on startup of the application South's migrate or syncdb offers to delete them. Is it possible to do something with the call to migrate/syncdb that automatically deletes these?
This prompt can't be exposed to the end user for obvious reasons, so I really hope there is some way we can take car of this automatically :)
I've seen that with the South migrate you can call --noinput
but that doesn't delete them, and it'd be good if we could do that as we know it'll be safe.
On unix systems there is a command yes
, which will repeatedly output a string to stdout, separated by newlines. We can use this to auto-answer this prompt.
yes "yes" | python ./manage.py migrate
I use this command to automatically answer yes in my scripts when I'm doing Django migrations:
cat <(echo "yes") - | ./manage.py syncdb --migrate
Note that this only takes care of the first prompt. You can read more about the details of how this works and how to add an automatic answer to a second prompt here:
https://stackoverflow.com/a/16347534/1636882
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With