我有这个错误
Name 'Order' is not defined
在以下条款中:
try:
order = Order.objects.from_request(request)
cart = OrderCart(order)
except Order.DoesNotExist:
pass
Order
在同一个文件中完全定义并且是model.Model
更具体地说,这是我正在使用的文件: https : //bitbucket.org/chris1610/satchmo/src/a04c87a539f3/satchmo/apps/satchmo_store/shop/models.py,第242行出现异常
为什么会这样?
更新:
这是回溯:
Traceback:
File "/home/evgeniuz/.virtualenvs/port/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "/home/evgeniuz/src/chillifish-pg/lib/payment/views/balance.py" in balance_remaining_order
30. template='shop/checkout/balance_remaining.html')
File "/home/evgeniuz/src/chillifish-pg/pg/pgstore/utils.py" in _view
38. return view_func(request, *args, **kwargs)
File "/home/evgeniuz/src/chillifish-pg/lib/payment/views/balance.py" in balance_remaining
66. 'paymentmethod_ct': len(config_value('PAYMENT', 'MODULES'))
File "/home/evgeniuz/.virtualenvs/port/lib/python2.7/site-packages/django/template/context.py" in __init__
149. self.update(processor(request))
File "/home/evgeniuz/src/chillifish-pg/lib/satchmo_store/shop/context_processors.py" in settings
21. cart = Cart.objects.from_request(request)
File "/home/evgeniuz/src/chillifish-pg/lib/satchmo_store/shop/models.py" in from_request
237. except Order.DoesNotExist:
Exception Type: NameError at /shop/checkout/balance/1/
Exception Value: global name 'Order' is not defined