Exemple #1
0
def investigatePost(request):
    if request.method == 'POST':
        submitted = request.POST['staff']
        new_record = Character(name=submitted)
        new_record.save()
    staff_list = Character.objects.all()
    return render(request, 'postform.html', {'staffs': staff_list})
def investigate(request):
    if request.POST:
        submitted = request.POST['staff']
        new_record = Character(name=submitted)
        new_record.save()
    ctx = {}
    ctx.update(csrf(request))
    all_records = Character.objects.all()
    ctx['staff'] = all_records
    return render(request, "investigate.html", ctx)
Exemple #3
0
def form(request):
    ctx = {}
    ctx.update(csrf(request))
    if request.POST:
        ctx['rlt'] = request.POST['staff']
        new_record = Character(name=ctx['rlt'])
        new_record.save()
    all_records = Character.objects.all()
    ctx['staff'] = all_records
    return render(request,'form.html',ctx)
Exemple #4
0
def investigate(request):
    if request.POST:
        submitted = request.POST["staff"]
        new_record = Character(name=submitted)
        new_record.save()
    ctx = {}
    ctx.update(csrf(request))
    all_records = Character.objects.all()
    ctx["staff"] = all_records
    return render(request, "investigate.html", ctx)
Exemple #5
0
def savestaff(request):
    if request.POST:
        submitted=request.POST['staff']
        new_record=Character(name=submitted)
        new_record.save()
    ctx={}
    ctx.update(csrf(request))
    all_records=Character.objects.all()
    ctx['staff']=all_records
    return render(request,'savestaff.html',ctx)
Exemple #6
0
def investigate(request):
    csx = {}
    csx.update(csrf(request))
    if request.POST:
        submmit = request.POST['staff']
        if len(submmit):
            new_record = Character(name=submmit)
            new_record.save()
    all_records = Character.objects.all()
    csx['staff'] = all_records
    return render(request, "investigate.html", csx)
Exemple #7
0
def investigate(request):
    csx = {}
    csx.update(csrf(request))
    if request.POST:
        submmit = request.POST['staff']
        if len(submmit):
            new_record = Character(name=submmit)
            new_record.save()
    all_records = Character.objects.all()
    csx['staff'] = all_records
    return render(request, "investigate.html", csx)
Exemple #8
0
def investigate(request):
    if request.POST:
        form = CharacterForm(request.POST)
        if form.is_valid():
            submitted = request.POST['name']
            new_record = Character(name=submitted)
            new_record.save()
    form = CharacterForm()
    ctx = {}
    ctx.update(csrf(request))
    all_records = Character.objects.all()
    ctx['form']=form
    ctx['staff'] = all_records
    return render(request,'investigate.html',ctx)
Exemple #9
0
def investigate(request):
    if request.POST:
        form = CharacterForm(request.POST)
        if form.is_valid():
            submitted = form.cleaned_data['name']
            new_record = Character(name = submitted)
            new_record.save()

    form = CharacterForm()
    ctx = {}
    all_records = Character.objects.all()
    ctx['staff'] = all_records
    ctx['form'] = form
    return render(request, "investigate.html", ctx) 
Exemple #10
0
def investigate(request):
    if request.POST:
        submitted = request.POST['staff']
        new_record = Character(name = submitted)
        new_record.save()


    form = CharacterForm()
    ctx = {}
    ctx.update(csrf(request))
    all_records = Character.objects.all()
    ctx['staff'] = all_records
    ctx['form'] = form
    return render(request, "investigate.html", ctx)
Exemple #11
0
def investigate(request):
    if request.POST:
        form = CharacterForm(request.POST)
        if form.is_valid():
            submitted  = form.cleaned_data['name']
            new_record = Character(name = submitted)
            new_record.save()
    form = CharacterForm()
    staff_list = Character.objects.all()
    staff_str  = map(lambda x:str(x.name), staff_list)
    context          = {}
    context.update(csrf(request))        
    context['label'] = 'Hello ' + ' '.join(staff_str)   
    context['form'] = form
    return render(request, 'templay.html', context)
Exemple #12
0
def investigate(request):
    if request.POST:
        form = CharacterForm(request.POST)
        if form.is_valid():
            submitted = form.cleaned_data['name']
            #  http://www.jb51.net/article/87046.htm  可查看文档
            new_record = Character(name=submitted)
            new_record.save()

    form = CharacterForm()
    ctx = {}
    ctx.update(csrf(request))
    all_records = Character.objects.all()
    ctx['staff'] = all_records
    ctx['form'] = form
    return render(request, "investigate.html", ctx)
Exemple #13
0
def investigate_form(request):
    if request.POST:
        form = CharacterForm(request.POST)
        print(request.POST)
        if form.is_valid():
            submitted = form.cleaned_data["name"]
            new_record = Character(name=submitted)
            print("save %s" % submitted)
            new_record.save()
    form = CharacterForm()
    ctx = {}
    ctx.update(csrf(request))
    all_records = Character.objects.all()
    ctx["staff"] = all_records
    ctx["form"] = form
    return render(request, "investigate_form.html", ctx)
Exemple #14
0
def investigate(request):
  #get method
  # rlt = request.GET['staff']
  # return HttpResponse(rlt)
  
  #post method
  ctx = {}
  if request.POST:
  #   ctx['rlt'] = request.POST['staff']
  # return render(request, "investigate.html", ctx)
  
  #将post 的数据 放到数据库中
    submitted = request.POST['staff']
    new_record = Character(name = submitted)
    new_record.save()
  all_records = Character.objects.all()
  ctx['staff'] = all_records
  return render(request, "investigate.html", ctx)
Exemple #15
0
def investigate(request):
    if request.POST:
        form = CharacterForm(request.POST)
        if form.is_valid():
            id_submitted = request.POST['id']
            name_submitted = request.POST['name']
            sex_submitted = request.POST['sex']
            new_record = Character(id=id_submitted,
                                   name=name_submitted,
                                   sex=sex_submitted)
            new_record.save()
    form = CharacterForm()
    ctx = {}
    ctx.update(csrf(request))
    all_records = Character.objects.all()
    ctx['staff'] = all_records
    ctx['form'] = form
    return render(request, 'investigate.html', ctx)
Exemple #16
0
def post_db(request):
	
	ctx = {}
	ctx.update(csrf(request))

	print '+++++++++++++++++++++'
	print request.scheme
	print request.body
	print request.path
	print request.path_info
	print request.method
	print request.encoding
	print request.GET
	print request.POST
	print request.META
	print request.user
	print request.session
	print request.resolver_match
	print request.get_full_path
	print request.build_absolute_uri()
	print request.readline()

	print '---------------------'

	if request.POST:

		ctx['staffs'] = request.POST['staffs']
		newrecord = Character(name = ctx['staffs'])
		newrecord.save()

		staff_list = Character.objects.all()

		form = CharacterForm()

		
		context = {'ht_title':'show value','ht_action':'showvalue','staffs':staff_list,'pythonform':form}
	else:
		form = CharacterForm()

		staff_list = Character.objects.all()
		context = {'ht_title':'show form','ht_action':'showform','staffs':staff_list,'pythonform':form}


	return render(request,'post_db.html',context)