我正在使用dj-stripe==1.0.0.post1
。我按照here提到的安装步骤进行了操作。
当我去django管理员并尝试创建计划时,我收到此错误
KeyError at /admin/djstripe/plan/add/ 'stripe_id'
这里是完整的堆栈跟踪:
ERROR 2017-09-27 11:07:57,600 django.request Internal Server Error:
/admin/djstripe/plan/add/
Traceback (most recent call last):
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args,
**callback_kwargs)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/contrib/admin/options.py", line 551, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/utils/decorators.py", line 149, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/views/decorators/cache.py", line 57, in
_wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/contrib/admin/sites.py", line 224, in inner
return view(request, *args, **kwargs)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/contrib/admin/options.py", line 1508, in add_view
return self.changeform_view(request, None, form_url, extra_context)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/utils/decorators.py", line 67, in _wrapper
return bound_func(*args, **kwargs)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/utils/decorators.py", line 149, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/utils/decorators.py", line 63, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/contrib/admin/options.py", line 1408, in
changeform_view
return self._changeform_view(request, object_id, form_url,
extra_context)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/django/contrib/admin/options.py", line 1448, in
_changeform_view
self.save_model(request, new_object, form, not add)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/djstripe/admin.py", line 298, in save_model
Plan.get_or_create(**form.cleaned_data)
File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site-
packages/djstripe/models.py", line 939, in get_or_create
return Plan.objects.get(stripe_id=kwargs['stripe_id']), False
KeyError: 'stripe_id'
我在这里缺少什么。我已经配置了安装指南中提到的所有内容
答案 0 :(得分:0)
好吧,你不应该从管理界面添加计划。 djstripe
希望您创建条带计划,让webhook在您的数据库中创建计划。
当然,您必须使用类似ngrok
的内容,这样您才能让条带将API调用发布到可公开访问的IP