【问题标题】:Setting up a subscription with Stripe - Django-stripe-payments - Error TemplateDoesNotExist使用 Stripe 设置订阅 - Django-stripe-payments - 错误 TemplateDoesNotExist
【发布时间】:2015-05-17 11:25:43
【问题描述】:

我正在尝试使用 django-stripe-payments 设置 Stripe 每月订阅。我已按照安装说明进行操作,但仍然遇到问题。

我已将付款添加到已安装的应用程序中,但出现 TemplateDoesNotExist 错误

我已经检查了 .../lib/python2.7/site-packages/payments/templates/payments/templates/payments/_subscribe_form.html 文件就在那里!但是回溯说 文件不存在

view.py

    @login_required
    def subscribe(request):
        form = PlanForm(request.POST or None)
        template = 'payments/templates/payments/_subscribe_form.html' 
        context = {
        "form": form,
        } 
        return render(request, template, context)

urls.py

    url(r"^payments/", include("payments.urls")),

追溯

TemplateDoesNotExist at /subscriptions/subscribe
payments/templates/payments/_subscribe_form.html
Request Method: GET
Request URL:    http://127.0.0.1:8000/subscriptions/subscribe
Django Version: 1.6.5
Exception Type: TemplateDoesNotExist
Exception Value:    
payments/templates/payments/_subscribe_form.html
Exception Location: /Users/andysair/Documents/personal/nmninja/lib/python2.7/site-packages/django/template/loader.py in find_template, line 131
Python Executable:  /Users/andysair/Documents/personal/nmninja/bin/python
Python Version: 2.7.5
Python Path:    
['/Users/andysair/Documents/personal/nmninja/nmninja',
 '/Users/andysair/Documents/personal/nmninja/lib/python27.zip',
 '/Users/andysair/Documents/personal/nmninja/lib/python2.7',
 '/Users/andysair/Documents/personal/nmninja/lib/python2.7/plat-darwin',
 '/Users/andysair/Documents/personal/nmninja/lib/python2.7/plat-mac',
 '/Users/andysair/Documents/personal/nmninja/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/andysair/Documents/personal/nmninja/Extras/lib/python',
 '/Users/andysair/Documents/personal/nmninja/lib/python2.7/lib-tk',
 '/Users/andysair/Documents/personal/nmninja/lib/python2.7/lib-old',
 '/Users/andysair/Documents/personal/nmninja/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/andysair/Documents/personal/nmninja/lib/python2.7/site-packages']
Server time:    Thu, 12 Mar 2015 22:34:56 +1100
Template-loader postmortem

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/Users/andysair/Documents/personal/nmninja/nmninja/templates/payments/templates/payments/_subscribe_form.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/Users/andysair/Documents/personal/nmninja/lib/python2.7/site-packages/django/contrib/admin/templates/payments/templates/payments/_subscribe_form.html (File does not exist)
/Users/andysair/Documents/personal/nmninja/lib/python2.7/site-packages/django/contrib/auth/templates/payments/templates/payments/_subscribe_form.html (File does not exist)
/Users/andysair/Documents/personal/nmninja/lib/python2.7/site-packages/django_forms_bootstrap/templates/payments/templates/payments/_subscribe_form.html (File does not exist)
/Users/andysair/Documents/personal/nmninja/lib/python2.7/site-packages/payments/templates/payments/templates/payments/_subscribe_form.html (File does not exist)

【问题讨论】:

  • 您的settings.py 文件的INSTALLED_APPS 变量中有应用程序吗?

标签: python django stripe-payments


【解决方案1】:

除了在您的 INSTALLED_APPS 中放置“付款”之外,将 base.html 文件中的 {% extends "site_base.html" %} 调整为您项目的 base.html 文件,即将 site_base.html 替换为您项目的基础。 html文件。

【讨论】:

    猜你喜欢
    • 2020-03-18
    • 2021-01-01
    • 1970-01-01
    • 2021-02-22
    • 2022-07-21
    • 1970-01-01
    • 2017-07-03
    • 2017-12-27
    • 2014-09-27
    相关资源
    最近更新 更多