コード例 #1
0
ファイル: views.py プロジェクト: SunZunSun/lab3git
def author_add(request):
    if request.POST:
        error = False
        if re.search(r'[^\d]',request.POST['year']):
            error = True
        try:
            if not error:
                post = request.POST
                if post['name']=="" or post['year']=='' or post['ID']=='':
                    return render_to_response("author_add.html",{'judge':False,})
                new_people = Author(
                    name = post["name"],
                    Age = post["year"],
                    Author_ID = post['ID'],
                    Country = post["Country"],
                    sex = True)    
                if post["sex"] == 'M':
                    new_people.sex = True
                else:
                    new_people.sex = False       
                new_people.save()
            else:
                return render_to_response("author_add.html",{'judge':False,})
        except:
            return render_to_response("author_add.html",{'judge':False,})
    return render_to_response("author_add.html",{'judge':True,})