我正在开发Django 1.10,Mezzanine 4.4.2,安装Mezzanine后手动安装了Cartridge。现在我可以通过墨盒添加产品和价格。但是当我点击“购买”按钮时,它会给我以下错误: -
AttributeError at /shop/product/nike-blue/
'WSGIRequest' object has no attribute 'cart'
Request Method: POST
Request URL: http://localhost:8000/shop/product/nike-blue/
Django Version: 1.10.3
Exception Type: AttributeError
Exception Value:
'WSGIRequest' object has no attribute 'cart'
Exception Location: G:\Py_Envs\Racknole\Mezzanine_Trial\lib\site-packages\cartridge\shop\views.py in product, line 69
Python Executable: G:\Py_Envs\Racknole\Mezzanine_Trial\Scripts\python.exe
Python Version: 2.7.11
Python Path:
['G:\\Django_Projects\\RackNole\\Mezzanine_Trial\\project_name',
'C:\\Windows\\SYSTEM32\\python27.zip',
'G:\\Py_Envs\\Racknole\\Mezzanine_Trial\\DLLs',
'G:\\Py_Envs\\Racknole\\Mezzanine_Trial\\lib',
'G:\\Py_Envs\\Racknole\\Mezzanine_Trial\\lib\\plat-win',
'G:\\Py_Envs\\Racknole\\Mezzanine_Trial\\lib\\lib-tk',
'G:\\Py_Envs\\Racknole\\Mezzanine_Trial\\Scripts',
'c:\\python27\\Lib',
'c:\\python27\\DLLs',
'c:\\python27\\Lib\\lib-tk',
'G:\\Py_Envs\\Racknole\\Mezzanine_Trial',
'G:\\Py_Envs\\Racknole\\Mezzanine_Trial\\lib\\site-packages']
Server time: Fri, 11 Nov 2016 11:11:07 +0000
此外,如果我点击结帐选项,它会显示一个空的购物车,然后当我点击继续购物时,它会将我重定向到我想要更改的http://localhost:8000/shop/
。
提前致谢。
答案 0 :(得分:1)
这个问题是由于缺少Cartridge的ShopMiddleware。将其添加到settings.py文件中:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
.......,
.......,
'cartridge.shop.middleware.ShopMiddleware',
)
如果问题进一步存在,请将您的settings.py文件与This link.
进行比较