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})
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})
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})
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())
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})
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})
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})
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})
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())
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})