django -- 对模式进行调式(pay with the api)

在django中如果想对models进行调试、不用每次都要runserver 在web界面上点点点、django自己带了字符界面的调试功能

 

一、完成app的注册、与models的定义:

  注册app:

  定义model:

 

 

二、调用shell调式接口:

JianglexingdeMacBook-Pro:project7 jianglexing$ python3 manage.py shell
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import django
>>> django.setup()
>>>
>>> from polls.models import Person
>>>
>>> Person.objects.all()
<QuerySet []>
>>> p=Person()
>>> p.name='1234'
>>> p.save()
>>> Person.objects.all()
<QuerySet [<Person: 1234>]>
>>> exit()

 

 

 

 

 

---

 

posted on 2017-12-01 09:28  蒋乐兴的技术随笔  阅读(183)  评论(0编辑  收藏  举报

导航