我正在学习本教程 http://www.sitepoint.com/building-simple-rest-api-mobile-applications/
我正在尝试运行 SQL
$ python manage.py sql fishes
不管怎么说
Unknown Command: 'sql'
如果我输入
$ python manage.py help
我明白了,SQL 没有出现在列表中。
Available subcommands:
[auth]
changepassword
createsuperuser
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver
最佳答案
不幸的是,它不再存在,但是命令 manage.py dbshell
存在。
但是,一般来说,您应该尝试使用模型,使用 load_data 等来保持数据完整性(因为验证等可能发生在模型中,而不是依赖于底层数据位)。或者为任何清理任务编写管理命令。
关于Python Django 未知命令 'SQL',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36066594/