'WSGIRequest' 对象在 django-cartridge 中没有属性 'cart'
'WSGIRequest' object has no attribute 'cart' in django-cartridge
我正在使用 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/
。
提前致谢。
此问题是由于缺少 Cartridge 的 ShopMiddleware。将此添加到您的 settings.py 文件中:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
.......,
.......,
'cartridge.shop.middleware.ShopMiddleware',
)
如果问题进一步存在,则将您的 settings.py 文件与 This link.
进行比较
我正在使用 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/
。
提前致谢。
此问题是由于缺少 Cartridge 的 ShopMiddleware。将此添加到您的 settings.py 文件中:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
.......,
.......,
'cartridge.shop.middleware.ShopMiddleware',
)
如果问题进一步存在,则将您的 settings.py 文件与 This link.
进行比较