コード例 #1
0
ファイル: views.py プロジェクト: captaintl/lll
def update(request):
    if request.POST:
        con=sqlite3.connect ('db.sqlite3')
        cur = con.cursor ()
        cur.execute ('delete from addr_book_people where id=?',(request.GET['id'],))
        con.commit()
        con.close()
        post = request.POST
        new_people = People(
        name = post["name"],
        number = post["number"],
        phone = post["phone"],
        QQ = post["QQ"],
        email = post["email"],
        address = post["address"],
        birth = post["birth"],)
        if post["sex"] == 'M':
            new_people.sex = True
        else:
            new_people.sex = False
        new_people.save()
        people_list = People.objects.all()
        c = Context({"people_list":people_list,}) 
        return render_to_response("updates.html",c)
    for people in People.objects.all():
        if int(request.GET['id'])==people.id:
            c = Context({"people":people,})
            return render_to_response("update.html",c)
コード例 #2
0
ファイル: views.py プロジェクト: 1014yzh/show-me-the-code
def insert( request ):
    if request.POST:
        post = request.POST
        new_people = People(
                name = post["name"],
                phone = post["phone"],
                email = post["email"],
                address = post["address"], )
        if post["sex"] == 'M':
            new_people.sex = True
        else:
            new_people.sex = False
        new_people.save()
        
    return render_to_response ( "insert.html" )
コード例 #3
0
ファイル: views.py プロジェクト: captaintl/lll
def add_people(request):
    global ids
    if request.POST:
        post = request.POST
        new_people = People(
        name = post["name"],
        number = post["number"],
        phone = post["phone"],
        QQ = post["QQ"],
        email = post["email"],
        address = post["address"],
        birth = post["birth"],)
        if post["sex"] == 'M':
            new_people.sex = True
        else:
            new_people.sex = False
        new_people.save()
    people_list = People.objects.all()
    c = Context({"people_list":people_list,})   
    return render_to_response("form.html",c)
コード例 #4
0
ファイル: views.py プロジェクト: feilifan/Project-1
def class_register(request):
    if request.POST:
        post = request.POST
        if post['code']==post['codex']:
            nickname =request.POST['name']
            code =request.POST['code']
            try:
                user = User.objects.create_user(username=nickname,password=code)
                user.save()
                new_people = People(user = user,
                                    email= post['email'],
                                    nickname = post['nickname'],
                                    name = post['name'],
                                    school_number = post['id'])
                new_people.save()
            except:
                return render_to_response("class_register.html",{'judge':True})
        else:
            error = Context({'judge':False})
            return render_to_response("class_register.html",error)
    error = Context({'judge':True})
    return render_to_response("class_register.html",error)