Пример #1
0
def create(request):
    book = BookInfo()
    book.btitle = 'liuxinghudiejian'
    book.bpub_date = date(1990, 1, 1)
    book.bcomment = 15
    book.bread = 10
    book.save()
    return HttpResponseRedirect('/index')
Пример #2
0
def create(request):
    # add a book in mysql and display in web page
    book = BookInfo()
    book.btitle = "笑傲江湖"
    book.isDelete = False
    book.bpub_date = datetime.now()
    book.bcomment = 25
    book.bread = 32
    book.save()
    return HttpResponseRedirect('/index3')
Пример #3
0
def create(request):
    # 新增一本图书
    book = BookInfo()
    book.btitle = "倚天屠龙记"
    book.bpub_date = date(1998, 2, 5)
    book.bread = 100
    book.bcomment = 59
    book.save()
    # 重定向,服务器不返回页面,而是告诉浏览器去请求其他的url
    return HttpResponseRedirect('/index')
Пример #4
0
def create(request):
    # 添加一个新的条目
    new_book = BookInfo()
    # 设置条目内包含的信息
    new_book.bname = "一本新书"
    new_book.bpub_date = date(1991, 1, 1)
    new_book.bread, new_book.bcomment = 100, 50
    # 保存新添加的条目
    new_book.save()
    # 添加完成后重定向到index, 此处输入的内容不是模板文件,而是要访问的 url地址
    # return HttpResponseRedirect('/index')
    return redirect('/index/')