Example #1
0
def add_vcluster(request):
    if request.method == 'POST':
        form = VclusterForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return vcluster(request)
        else:
            print form.errors
    else:
        form = VclusterForm()
    return render(request, 'cmdb/add_vcluster.html', {'form': form})
Example #2
0
def edit_vcluster(request):
    if request.method == 'POST':
        r_id = request.POST["id"]
        vcluster_info = CM_VCLUSTER.objects.get(id=r_id)  # 获取要更改行
        form = VclusterForm(request.POST, instance=vcluster_info)
        if form.is_valid():
            form.save()
            return vcluster(request)
        else:
            print form.errors
    else:
        form = VclusterForm()
    return render(request, 'cmdb/add_vcluster.html', {'form': form})