Django Shell
django shell主要用来做调试工作,非常好用
启动django shell
在cmd下使用: python manage.py shell
案例1: 调用models.py访问数据库
D:\python\myblog>python manage.py shell Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from blog.models import Article >>> Article.objects.get(id=1) <Article: hello> >>> Article.objects.all() <QuerySet [<Article: hello>, <Article: hello2>, <Article: 你好中国>, <Article: Django>]> >>>
案例2: 查询未知方法
未完待续......