我正在编写一个在创建 docker 容器时运行的 startup.sh 脚本。
#!/bin/bash
python manage.py runserver
python manage.py makemigrations accounts
python manage.py migrate
python manage.py check_permissions
python manage.py cities --import=country --force
*python manage.py shell | from cities.models import * Country.objects.all().exclude(name='United States").delete()*
python manage.py cities --import=cities
python manage.py cities --import=postal_code
我猜有问题的行不正确,在 bash 脚本中执行此操作的正确方法是什么?
请您参考如下方法:
使用 heredoc:
python manage.py shell <<'EOF'
from cities.models import *
Country.objects.all().exclude(name='United States').delete()
EOF
