예제 #1
0
파일: views.py 프로젝트: 2020668/tester
def create(request):
    b = BookInfo()
    b.btitle = '流星蝴蝶剑'
    b.bpub_date = date(1990, 1, 1)
    b.save()
    # 让浏览器再次访问index,重定向
    return redirect('/index')
예제 #2
0
def create(request):
    b = BookInfo()
    b.btitle = 'liuxinghudiejian'
    b.bpub_date = date(1990,1,1)
    b.save()
    #return HttpResponseRedirect('/index')
    return redirect('/index')
예제 #3
0
파일: views.py 프로젝트: eryeer/pythonStudy
def create(request):
    book_info = BookInfo()
    book_info.btitle = "射雕英雄传"
    book_info.bpub_date = date(1977, 1, 1)
    book_info.bcomment = 3
    book_info.save()
    return HttpResponseRedirect("/index")
예제 #4
0
파일: views.py 프로젝트: shuzk/szkDjango021
def create(request):
    book = BookInfo()
    book.btitle = "流星蝴蝶剑"
    book.bpub_date = date(1995, 12, 30)
    book.save()
    # 转向到首页
    return redirect("/")
예제 #5
0
def create(request):
    book = BookInfo()
    book.btitle = '你的名字'
    book.bpub_date = date(1991, 1, 1)
    book.save()
    # 跳转到首页
    return redirect('/')
예제 #6
0
def addBook(request):
    book = BookInfo()
    book.btitle = '晓可自传'
    book.bpub_date = date(2017, 6, 27)
    book.save()
    # return HttpResponse('ok')
    # 重定向跳转到首页
    return redirect('/index/')
예제 #7
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')
예제 #8
0
def create(request):
    b = BookInfo()
    b.btitle = '风月宝鉴'
    from datetime import date
    b.bpub_date = date(1153,2,3)
    b.save()

    return redirect('/')
예제 #9
0
def add_book(request):
    """添加图书"""
    book = BookInfo()
    book.btitle = "西游记"
    book.bpub_date = date(1991, 1, 2)
    book.save()

    # 反应完成,让浏览器 再吃访问同一页面 这个也叫作重定向
    return HttpResponseRedirect('/index')
예제 #10
0
def create(request):
    #1. 新增一本图书
    b = BookInfo()
    b.btitle = '流行蝴蝶剑'
    b.bpub_date = date(1992, 10, 11)
    b.save()
    #2. 返回内容;重定向到index页面
    #return HttpResponse('OK')
    return redirect('/index')
예제 #11
0
파일: views.py 프로젝트: SHOST628/djangop1
def create(request):
    # create a new book
    b = BookInfo()
    b.btitle = '流星蝴蝶剑'
    b.bpub_date = date(1990, 1, 1)
    b.save()
    # return HttpResponse('ok')
    # return HttpResponseRedirect('/index')
    return redirect('/index')
예제 #12
0
def create(request):
    b = BookInfo()
    b.btitle = '流星蝴蝶剑1'
    b.bpub_date = date(2020, 1, 1)
    b.save()
    # 返回应答,让浏览器在访问首页
    # return HttpResponse('ok')
    # return HttpResponseRedirect('/index')
    return redirect('/index')
예제 #13
0
def addBook(request):
    book = BookInfo()
    book.btitle = u'mysql操作_auto_自动_lby'
    book.bpub_date = datetime.now()
    book.save()
    # return HttpResponse('ok')
    # sql操作
    addBookSql()
    # 重定向跳转到首页
    return redirect(u'/index/')
예제 #14
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')
예제 #15
0
파일: views.py 프로젝트: LF-Wow/DjangoTest
def add(request):
    '''添加书'''
    # 创建书
    book = BookInfo()
    book.btitle = "流星蝴蝶剑"
    book.bpub_date = date(1990, 1, 1)
    book.save()
    # 返回应答,再次访问本页面,重定向
    # return HttpResponseRedirect('/booktest')
    return redirect('/booktest')
예제 #16
0
파일: views.py 프로젝트: ht5678/yzh-learn
def create(request):
    '''新增一本图书'''
    #创建BookInfo对象
    b = BookInfo();
    b.btitle = '流星蝴蝶剑';
    b.bpub_date=date(1990,1,1);
    #保存进数据库
    b.save();
    #返回应答,让浏览器再访问/index
    return HttpResponseRedirect('/books');
예제 #17
0
def create(request):
    '''新增一本书'''
    b = BookInfo()
    b.btitle = '同学两亿岁'
    b.bpub_date = date(1990, 1, 1)
    # 保存进数据库
    b.save()
    # 返回应答
    # return HttpResponse('ok')
    return HttpResponseRedirect('/index')  # 让浏览器自动返回/index页面
예제 #18
0
파일: views.py 프로젝트: jinkaka180/test-py
def create(request):
    '''新增一本图书'''
    # 1.创建BookInfo对象
    b = BookInfo()
    b.btitle = '流星蝴蝶剑'
    b.bpub_date = date(1990, 1, 1)
    # 2.保存进数据库
    b.save()
    # 3.返回应答,让浏览器再访问/index,重定向
    return HttpResponse('ok')
예제 #19
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')
예제 #20
0
def create(request):
    '''新增一本图书'''
    # 1.创建一个对象
    b = BookInfo()
    b.btitle = '遮天'
    b.bpub_date = date(2000, 1, 1)
    # 2.保存进数据
    b.save()
    # 3.返回应答,让浏览器访问回/index(重定向)
    return HttpResponseRedirect("/index")
예제 #21
0
def create(request):
    '''新增一本图书'''
    #创建对象
    b = BookInfo()
    b.btitle = '流星蝴蝶剑'
    b.bpub_date = date(1990, 2, 1)
    b.save()

    #返回应答,让浏览器再访问/index,重定向
    #return HttpResponseRedirect('/index')
    return redirect('/index')
예제 #22
0
def create(request):
    """新增一本图书"""
    # 创建Bookinfo对象
    b = BookInfo()
    b.btitle = '流行蝴蝶剑'
    b.bpub_date = date(2009, 5, 6)
    # 保存进数据库
    b.save()
    # 返回应答, 让浏览器再访问/index
    # return HttpResponse('OK')
    return HttpResponseRedirect('/index')
예제 #23
0
def create(request):
    '''下次你曾一本涂书'''
    # 1 新建bookinfo对象
    b = BookInfo()
    b.btitle = '流星蝴蝶剑'
    b.bpub_date = date(1999, 1, 1)
    # 保存今数据库
    b.save()
    # 3 返回应答,让浏览器在访问index
    '''重定向  使用重定向函数'''
    return redirect('/index')
예제 #24
0
def save(request):
    # 使用模版文件,传递数据到模版
    # 重定向
    b = BookInfo()
    b.btitle = "123321"
    b.bpub_date = date(1990, 1, 1)
    b.save()
    # 重定向
    # return HttpResponseRedirect("/books")
    # 直接使用重定向即可
    return redirect("/books")
예제 #25
0
def create(request):
    '''新增书籍'''
    # 1. 创建BookInfo对象
    b = BookInfo()
    b.btitle = '流星蝴蝶剑2'
    b.bpub_date = date(1990,1,4)
    # 2. 保存数据库
    b.save()
    # 3.返回应答
    # return HttpResponse('ok') # 保存数据了,但是u跳转了
    # return HttpResponseRedirect('/index') # 重定向
    return redirect('/index') # 重定向内部重写HttpResponseRedirect
예제 #26
0
파일: views.py 프로젝트: zhoupeak/webapp
def create(request):
    '''新增一本图书'''
    print('-----------------------------------------------')
    # 1.创建BookInfo对象
    b = BookInfo()
    b.btitle = '流星蝴蝶剑'
    b.bpub_date = date(1990,1,1)
    # 2.保存进数据库
    b.save()
    # 3.返回应答,让浏览器再访问/index,重定向
    # return HttpResponse('ok')
    return HttpResponseRedirect('/tushu/index')
예제 #27
0
def create(request):
    '''新增一本图书'''
    # 1.创建一个bookinfo对象
    b = BookInfo()
    b.btitle = '流星蝴蝶剑'
    b.bpub_date = date(1990, 1, 1)
    # 2.保存进数据库
    b.save()
    # 3.返回应答
    # return HttpResponse('ok')
    # 让浏览器返回首页
    return HttpResponseRedirect('/index')
예제 #28
0
파일: views.py 프로젝트: HuXifan/Dj_test2
def create(request):
    '''新增一本书'''
    # 1 创建一个BookInfo对象
    b = BookInfo()
    b.btitle = '倚天屠龙记'
    b.bpub_date = date(2012, 4, 30)
    # 2 保存数据库
    b.save()
    # f返回应答,让浏览器访问首页index,重定向
    # return HttpResponse('OK')  # 返回给浏览器显示内容
    # return HttpResponseRedirect('/index')  # HttpResponseRedirect 参数写浏览器访问的地址
    return redirect('/index')  # 同上
예제 #29
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/')
예제 #30
0
def create(request):
    '''新增图书'''
    # 1.创建图书对象
    book = BookInfo()
    # 2.给新增图书添加属性
    book.btitle = '流星蝴蝶剑'
    book.bpub_date = date(1992,1,3)
    # 3.保存进数据库
    book.save()
    # 4.重定向访问/index
    # return HttpResponseRedirect('/index') #将页面重定向到index页面
    return redirect('/index')