I have this error
Name 'Order' is not defined
in the following claue:
try:
order = Order.objects.from_request(request)
cart = OrderCart(order)
except Order.DoesNotExist:
pass
Order
is defined exactly in the same file and is subclass of model.Model
To be more concrete, here is the file I'm working with: https://bitbucket.org/chris1610/satchmo/src/a04c87a539f3/satchmo/apps/satchmo_store/shop/models.py with exception occuring in line 242
Why can this be?
Update:
Here is the traceback:
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
Maybe I'm just missing something, but you're referring to the Order class in your CartManager before it's defined. Order isn't defined until line 642. I don't know a lot about the inner workings of Django, but I would try moving the Order class up above CartManager and see if it gets you past this error.