def edit(request, pid): payment = None try: payment = Payment.objects.get(id=int(pid)) except Payment.DoesNotExist: messages.warning(request, u"La référence de transaction demandée n'a pas été trouvée") return redirect("ogre_bank") form = PaymentForm(request.POST or None, instance=payment) if request.method == 'POST': if form.is_valid(): form.save() return redirect("ogre_bank") return render(request, "ogre/bank/edit.html", { 'form': form, 'payment': payment, })
def add(request): form = PaymentForm(request.POST or None) if request.method == 'POST': if form.is_valid(): payment = form.save() messages.info(request, u"La transaction ({}) a bien été ajoutée".format(payment)) return redirect("ogre_bank") return render(request, "ogre/bank/add.html", { 'form': form, })