Exemple #1
0
def add_os(request):
    if request.method == 'POST':
        form = OSForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return os(request)
        else:
            print form.errors
    else:
        form = OSForm()
    return render(request, 'cmdb/add_os.html', {'form': form})
Exemple #2
0
def edit_os(request):
    if request.method == 'POST':
        r_id = request.POST["id"]
        os_info = CM_OS.objects.get(id=r_id)  # 获取要更改行
        form = OSForm(request.POST, instance=os_info)
        if form.is_valid():
            form.save()
            return os(request)
        else:
            print form.errors
    else:
        form = OSForm()
    return render(request, 'cmdb/add_os.html', {'form': form})