此方法依赖的表时之前创建的过的一张表

参考链接:https://www.cnblogs.com/apollo1616/p/9840354.html

方法1:

# 语法
        [变量] = [表名].objects.create(字段1=值1, 字段2=值2, 字段3=值3, 字段4=值4, 字段5=值5, ......)

 

    给表插入多条数据
    book_obj = Bookinfo.objects.create(book_category='PYTHON', book_name='Python入门经典', book_author='Apollo',
                                       book_price=158, book_pubdate='2018-1-23', book_publish='邮电出版社')
    book_obj = Bookinfo.objects.create(book_category='PYTHON', book_name='Python学习手册', book_author='Joe',
                                       book_price=158, book_pubdate='2018-1-23', book_publish='邮电出版社')
    book_obj = Bookinfo.objects.create(book_category='PYTHON', book_name='Python核心编程', book_author='Jack',
                                       book_price=158, book_pubdate='2018-1-23', book_publish='邮电出版社')
    book_obj = Bookinfo.objects.create(book_category='PYTHON', book_name='Python基础教程', book_author='Eva',
                                       book_price=158, book_pubdate='2018-1-23', book_publish='邮电出版社')
    book_obj = Bookinfo.objects.create(book_category='JAVA', book_name='Java编程思想', book_author

 

方法2:

book_obj=Book(book_category='PYTHON',book_name='Python入门经典',book_author='Apollo',book_price=158,book_pubdate=2018-1-23,book_publish=邮电出版社)
book_obj.save()