コード例 #1
0
ファイル: views.py プロジェクト: SilenceWk/wangkai
def typeinsert(request):
    try:
        ob = Types()
        ob.name = request.POST['name']
        ob.pid = request.POST['pid']
        ob.path = request.POST['path']
        ob.save()
        context = {'info': '添加成功!'}
    except:
        context = {'info': '添加失败!'}
    return render(request, 'myadmin/info.html', context)
コード例 #2
0
def typesinsert(request):
    # try:
    ob = Types()
    ob.name = request.POST['name']
    print(ob.name)
    ob.pid = request.POST['pid']
    ob.path = request.POST['path']
    ob.save()
    context = {'info': '添加成功!'}
    # except:
    # 	context = {'info':'添加失败!'}
    return render(request, "myadmin/info.html", context)
コード例 #3
0
def do_typeadd(request):
    try:
        type = Types()
        type.name = request.POST['name']
        type.pid = request.POST['pid']
        type.path = request.POST['path']
        type.save()
        context = {"info":"添加成功"}
    except:
        context = {"info":"内部异常"}

    return render(request,'myadmin/info.html', context)
コード例 #4
0
 def post(self, request):
     try:
         get_pid = request.POST.get('pid')
         tmq_add = Types()
         tmq_add.name = request.POST.get('type_name')
         tmq_add.pid = get_pid
         if get_pid == '0':
             res = '%s,' % get_pid
         else:
             tem = Types.objects.get(id=get_pid)
             res = '%s%s,' % (tem.path, get_pid)
         tmq_add.path = res
         tmq_add.save()
         # return render(request, "myadmin/types_list/index.html")
         return redirect(reverse('myadmin_type_index'))
     except:
         return render(request, "myadmin/types_list/index.html")