成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

Django中shell命令的使用

瀏覽:171日期:2024-09-06 17:13:34
shell工具

Django的manage工具提供了shell命令,幫助我們配置好當(dāng)前工程的運行環(huán)境(如連接好數(shù)據(jù)庫等),以便可以直接在終端中執(zhí)行測試python語句。

通過如下命令進(jìn)入shell

python manage.py shell

Django中shell命令的使用

導(dǎo)入兩個模型類,以便后續(xù)使用

from book.models import BookInfo,PeopleInfo

此文的shell 是 manage工具的 一條命令

還記得之前創(chuàng)建的管理員嘛,用的也是 manage命令,那我們說說這個 manage

Django的命令行工具

django-admin.py是Django的一個用于管理任務(wù)的命令行工具,manage.py是對django-admin.py的簡單包裝,每個Django Project里面都會包含一個manage.py

django-admin.py <subcommand> [options]manage.py <subcommand> [options]

subcommand是子命令;options是可選的

# 常用子命令:startproject:創(chuàng)建一個項目(*)startapp:創(chuàng)建一個app(*)runserver:運行開發(fā)服務(wù)器(*)shell:進(jìn)入django shell(*)dbshell:進(jìn)入django dbshellcheck:檢查django項目完整性flush:清空數(shù)據(jù)庫compilemessages:編譯語言文件makemessages:創(chuàng)建語言文件makemigrations:生成數(shù)據(jù)庫同步腳本(*)migrate:同步數(shù)據(jù)庫(*)showmigrations:查看生成的數(shù)據(jù)庫同步腳本(*)sqlflush:查看生成清空數(shù)據(jù)庫的腳本(*)sqlmigrate:查看數(shù)據(jù)庫同步的sql語句(*)dumpdata:導(dǎo)出數(shù)據(jù)loaddata:導(dǎo)入數(shù)據(jù)diffsettings:查看你的配置和django默認(rèn)配置的不同之處

manage.py 特有的一些子命令:

createsuperuser:創(chuàng)建超級管理員(*)changepassword:修改密碼(*)clearsessions:清除session

更改開發(fā)服務(wù)器的端口:

python manage.py runserver 8080

查看幫助文檔:

python manage.py help

D:day70class>python manage.py helpType ’manage.py help <subcommand>’ for help on a specific subcommand.Available subcommands:[auth] changepassword createsuperuser[contenttypes] remove_stale_contenttypes[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

到此這篇關(guān)于Django中shell命令的使用的文章就介紹到這了,更多相關(guān)Django shell命令內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Django
相關(guān)文章: