Search code examples
pythondjangopaypaldjango-paypalbraintree

TemplateSyntaxError : No module named braintree in paypal template?


I am making a project that sells product and I want to have a payment using paypal in my django. but I got this error :

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

In my settings.py i have already put 'paypal.standard.ipn' in INSTALLED_APPS and the PAYPAL_RECEIVER_EMAIL.

When I check to my python shell..

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

it means, it is working...

In my urls.py, I have this:

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

In my 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": "[email protected]",
           "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)
 ......

and my template pay_pay.html have only this:

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

I think the problem is in rendering the pay_pay.html in my views... why i got this error:

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

Does anyone have an idea about my situation?


Solution

  • Type pip install braintree in a terminal and reload your server.