python - 模板语法错误 : No module named braintree in paypal template?

标签 python django paypal django-paypal braintree

我正在做一个销售产品的项目 我想在我的 django 中使用 paypal 付款。但我得到了这个错误:

'billing_tags' is not a valid tag library: ImportError raised loading billing.templatetags.billing_tags: No module named braintree

在我的 settings.py 中,我已经将 'paypal.standard.ipn' 放入 INSTALLED_APPSPAYPAL_RECEIVER_EMAIL.

当我查看我的 python shell 时..

>>> from billing import get_integration
>>> get_integration("pay_pal")
<billing.integrations.pay_pal_integration.PayPalIntegration object at 0x9d41b0c>

这意味着,它正在工作......

在我的 urls.py 中,我有这个:

from billing import get_integration
pay_pal = get_integration("pay_pal")
urlpatterns = patterns('',
    (r'^paypal-ipn-handler/', include(pay_pal.urls)),
)

在我的 views.py 中:

from billing import get_integration
from paypal.standard.forms import PayPalPaymentsForm
def booking_save_page(request, id):
.....
form = BookTicketForm(request.GET)
if form.is_valid():
    inst = Ticket.objects.create(
               date_select = form.cleaned_data['date_select'],
               product_name = product.name,
               quantity = form.cleaned_data['quantity'],
               totalcost = form.cleaned_data['totalcost'],
               price = form.cleaned_data['price'],
               first_name = form.cleaned_data['first_name'],
               last_name = form.cleaned_data['last_name'],
               contact = form.cleaned_data['contact'],
               product = product,
               client = client,
               trans_code = code,
               email = form.cleaned_data['email'],
               memo = form.cleaned_data['memo'],
               status = 'Pending',
               created = now,
               )
    pay_pal = get_integration("pay_pal")
    pay_pal.add_fields({
           "business": "ccfiel@gmail.com",
           "item_name": product.name,
           "invoice": inst.id,
           "notify_url": settings.BASE_DNS + "/paypal-ipn-handler/",
           "return_url": settings.BASE_DNS + str(client.id) + '/book/'+str(inst.id) +'/success/?booksaved=1',
           "cancel_return": settings.BASE_DNS + str(client.id) + '/?booksaved=0',
           "amount": inst.totalcost})
    form = PayPalPaymentsForm(initial=pay_pal)
    context = {"form": form}
    return render_to_response("pay_pay.html", context)
 ......

我的模板 pay_pay.html 只有这个:

<h1>Pay Here</h1>
{{ form.render }}

我认为问题在于在我的 View 中呈现 pay_pay.html...为什么我会收到此错误:

'billing_tags' is not a valid tag library: ImportError raised loading billing.templatetags.billing_tags: No module named braintree

有人知道我的情况吗?

最佳答案

在终端中输入 pip install braintree 并重新加载您的服务器。

关于python - 模板语法错误 : No module named braintree in paypal template?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8815837/

相关文章:

python - 如何使用我的 python 包分发字体?

python - pymc 中的标准化贝叶斯 IRT 模型

python - 如何确认表单已通过 django 提交?

python - Django ORM 查询 : getting "has many" relation objects

ruby-on-rails - 如何在没有 SSL 证书的情况下设置定期付款选项?

python - 如何在 scikit-learn 中正确执行交叉验证?

python - Django 和 psycopg2 : FATAL: password authentication failed for user

python - build_attrs() 得到了一个意外的关键字参数 'type'

php - paypal ipn 未通过验证

python - 如何使用 python 在 Windows 中关闭文件资源管理器