django -- 对行的更新只有在save调用后才会入库

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 Blog,Entry,Author
>>> Blog.objects.all()
<QuerySet []>
>>> b = Blog(name='Beatles Blog', tagline='All the latest Beatles news.')
>>> b.save()
>>> Blog.objects.all()
<QuerySet [<Blog: Beatles Blog>]>
>>> b.name='New name'
>>> Blog.objects.all()
<QuerySet [<Blog: Beatles Blog>]>
>>> b.save()
>>> Blog.objects.all()
<QuerySet [<Blog: New name>]>

 

 

 

 

 

 

----

 

posted on 2017-12-04 11:30  蒋乐兴的技术随笔  阅读(243)  评论(0编辑  收藏  举报

导航