Exemplo n.º 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)
Exemplo n.º 3
0
Arquivo: views.py Projeto: ckid/django
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)
Exemplo n.º 4
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) 
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
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)