Forums

AttributeError at /cart/cart-detail/

Hi,

I am getting attribute error when I am calling total_price function from site packages. It is working perfectly fine on my local server. All other functions are working except def total_price(). Below is what I am getting 'Cart' object has no attribute 'total_price'

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/usr/local/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, callback_args, *callback_kwargs) File "/home/Mariakh/Ecommerce/FoodShop/views.py", line 142, in cart_detail total = cart.total_price()

Exception Type: AttributeError at /cart/cart-detail/ Exception Value: 'Cart' object has no attribute 'total_price'

Could you please help out?

That's just saying that your class Cart (which I imagine is a Django model) does not define a method called total_price. You should check the code for that class.