Python Django 未知命令 'SQL'

标签 python sql django

我正在学习本教程 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 dbshel​​l 存在。

但是,一般来说,您应该尝试使用模型,使用 load_data 等来保持数据完整性(因为验证等可能发生在模型中,而不是依赖于底层数据位)。或者为任何清理任务编写管理命令。

关于Python Django 未知命令 'SQL',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36066594/

相关文章:

Django rest_framework,在特定方法中禁用身份验证和权限

python - 在执行 cpu 密集型任务时如何保持 pyqt GUI 响应?

sql - 是否可以在数据库中找到所有具有系统生成名称的主键?

python - 在Django中对要请求的图片进行排队

python - 从 Django 的类外部使用 super() (或替代它,如果有的话)

sql - 具有 session 变量的 postgresql 行级安全性

Python 矩阵

python - 在Python中将 float 转换为十进制类型

python - 如何计算长时间序列数据中连续事件的数量

php - 为每个 K2 项目选择所有类别