コード例 #1
0
def payment_add(request):
    """编辑付费记录"""
    if request.method == 'GET':
        form = PaymentForm()
        return render(request, 'web/payment_edit.html', {'form': form})
    form = PaymentForm(data=request.POST)
    if form.is_valid():
        form.save()
        return redirect('/payment/list/')
    return render(request, 'web/payment_edit.html', {'form': form})
コード例 #2
0
def payment_edit(request, pid):
    """新增付费记录"""
    obj = models.Payment.objects.get(id=pid)
    if request.method == 'GET':
        form = PaymentForm(instance=obj)
        return render(request, 'web/payment_add.html', {'form': form})
    form = PaymentForm(data=request.POST, instance=obj)
    if form.is_valid():
        form.save()
        return redirect('/payment/list/')
    return render(request, 'web/payment_add.html', {'form': form})
コード例 #3
0
ファイル: payment.py プロジェクト: ohoo2454/shiyanlou-code
def payment_add(request):
    """
    新增付费记录
    :return:
    """
    if request.method == 'GET':
        form = PaymentForm()
        return render(request, 'payment_add.html', {'form': form})
    form = PaymentForm(data=request.POST)
    if form.is_valid():
        form.save()
        return redirect(reverse('payment-list'))
    return render(request, 'payment_add.html', {'form': form})
コード例 #4
0
def payment_add(request):
    """
    编辑付费记录
    :return:
    """
    if request.method == 'GET':
        form = PaymentForm()
        return render(request, 'web/form_submit.html', context=locals())
    form = PaymentForm(data=request.POST)
    if form.is_valid():
        form.save()
        return redirect('/web/payment/list/')
    return render(request, 'web/form_submit.html', context=locals())
コード例 #5
0
ファイル: payment.py プロジェクト: ohoo2454/shiyanlou-code
def payment_edit(request, pid):
    """
    编辑付费记录
    :return:
    """
    obj = Payment.objects.get(id=pid)
    if request.method == 'GET':
        form = PaymentForm(instance=obj)
        return render(request, 'payment_edit.html', {'form': form})
    form = PaymentForm(data=request.POST, instance=obj)
    if form.is_valid():
        form.save()
        return redirect(reverse('payment-list'))
    return render(request, 'payment_edit.html', {'form': form})
コード例 #6
0
def payment_edit(request, pid):
    '''
    编辑付费记录
    :param request:
    :return:
    '''
    obj = models.Payment.objects.get(id=pid)
    form = PaymentForm(instance=obj)
    if request.method == 'POST':
        form = PaymentForm(data=request.POST, instance=obj)
        if form.is_valid():
            form.save()
            return redirect('/payment/list/')
    return render(request, 'payment_edit.html', {'form': form})
コード例 #7
0
def payment_add(request):
    '''
    添加付费记录
    :param request:
    :return:
    '''
    form = PaymentForm()
    if request.method == 'POST':
        form = PaymentForm(data=request.POST)
        print("form:", form)
        if form.is_valid():
            form.save()
            return redirect('/payment/list/')
    return render(request, 'payment_add.html', {'form': form})
コード例 #8
0
def payment_add(request):
    """
    新增付费记录
    :param request:
    :return:
    """
    if request.method == 'GET':
        form = PaymentForm()
        return render(request, 'payment_add.html', {'form': form})
    form = PaymentForm(data=request.POST)
    if form.is_valid():
        form.save()
        return redirect('/payment/list/')
    return render(request, 'payment_add.html', {'form': form})
コード例 #9
0
def payment_edit(request, pid):
    """
    编辑付费记录
    :return:
    """
    obj = models.Payment.objects.get(id=pid)
    if request.method == 'GET':
        form = PaymentForm(instance=obj)
        return render(request, 'web/form_submit.html', context=locals())
    form = PaymentForm(data=request.POST, instance=obj)
    if form.is_valid():
        form.save()
        return redirect('/web/payment/list/')
    return render(request, 'web/form_submit.html', context=locals())
コード例 #10
0
def payment_edit(request, pid):
    """
    修改付费记录
    :param request:
    :return:
    """
    try:
        obj = models.Payment.objects.get(id=pid)
    except Exception as e:
        print("修改付费记录找不到信息:", e)

    if request.method == 'GET':
        form = PaymentForm(instance=obj)
        return render(request, 'payment_edit.html', {'form': form})

    if request.method == 'POST':
        form = PaymentForm(data=request.POST, instance=obj)
        if form.is_valid():
            form.save()
            return redirect('/payment/list/')
        return render(request, 'payment_edit.html', {'form': form})