Exemple #1
0
def add_db(request):
    if request.method == 'POST':
        form = DatabaseForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return db(request)
        else:
            print form.errors
    else:
        form = DatabaseForm()
    return render(request, 'cmdb/add_db.html', {'form': form})
Exemple #2
0
def edit_db(request):
    if request.method == 'POST':
        r_id = request.POST["id"]
        db_info = CM_DATABASE.objects.get(id=r_id)  # 获取要更改行
        form = DatabaseForm(request.POST, instance=db_info)
        if form.is_valid():
            form.save()
            return db(request)
        else:
            print form.errors
    else:
        form = DatabaseForm()
    return render(request, 'cmdb/add_db.html', {'form': form})