【问题标题】:How integrate views in new django app如何在新的 django 应用程序中集成视图
【发布时间】:2024-05-21 06:10:02
【问题描述】:

我有 django-paypal views.py:

    from paypal.standard.forms import PayPalPaymentsForm

    def view_that_asks_for_money(request):

     paypal_dict = {
    "business": settings.PAYPAL_RECEIVER_EMAIL,
    "amount": "10000000.00",
    "item_name": "name of the item",
    "invoice": "unique-invoice-id",
    "notify_url": "https://www.example.com" + reverse('paypal-ipn'),
    "return_url": "https://www.example.com/your-return-location/",
    "cancel_return": "https://www.example.com/your-cancel-location/",

}

# Create the instance.
form = PayPalPaymentsForm(initial=paypal_dict)
context = {"form": form}
return render_to_response("payment.html", context)

我必须如何将它包含在我的基本应用示例中,以便所有功能都能正常工作并呈现 payment.html

【问题讨论】:

    标签: python django paypal django-paypal


    【解决方案1】:

    PayPalPaymentsForm 应该是一个对象,而不是一个字典。 因此,您可以构建一个对象作为参数。 例如:

         form = PayPalPaymentsForm()
         form.businness = paypal_dict["bussiness"]
    

    【讨论】: