shell 模式下循环添加测试数据
1、shell 模式下循环添加测试数据
举例:博客
导入models
>>> from blog.models import Blog,BlogType
>>> from django.contrib.auth.models import User
>>> user = User.objects.all()[0]
>>> type = BlogType.objects.all()[4]
>>> for i in range(1,61):
... blog = Blog()
... blog.title = "测试 %s" % i
... blog.content = "测试 %s" % i
... blog.blog_type = type
... blog.author = user
... blog.save()
上一篇
下一篇