# 6- Creating Order Items | Failure by adding Items into the cart

**URL:** <https://forum.codewithmosh.com/t/6-creating-order-items-failure-by-adding-items-into-the-cart/20520>\
**Category:** Django\
**Created:** [May 29, 2023, 7:59pm UTC](https://forum.codewithmosh.com/t/6-creating-order-items-failure-by-adding-items-into-the-cart/20520 "2023-05-29T19:59:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trycos](https://avatars.discourse-cdn.com/v4/letter/t/eada6e/32.png) [@Trycos](https://forum.codewithmosh.com/u/Trycos)\
**Post date:** [May 29, 2023, 7:59pm UTC](https://forum.codewithmosh.com/t/6-creating-order-items-failure-by-adding-items-into-the-cart/20520/1 "2023-05-29T19:59:32Z")

</div>

Hi Guys  
I have some issue, by adding parts (Start roughly at 3:00) and if I add a product into the cart I get some failure as follow:

[29/May/2023 19:57:28] “GET /store/carts/f9532386-9ada-4638-a672-a206af143cd3/items/ HTTP/1.1” 200 18537  
Internal Server Error: /store/carts/f9532386-9ada-4638-a672-a206af143cd3/items/  
Traceback (most recent call last):  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/django/core/handlers/exception.py”, line 55, in inner  
response = get\_response(request)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/django/core/handlers/base.py”, line 197, in \_get\_response  
response = wrapped\_callback(request, \*callback\_args, \*\*callback\_kwargs)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/django/views/decorators/csrf.py”, line 56, in wrapper\_view  
return view\_func(\*args, \*\*kwargs)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/rest\_framework/viewsets.py”, line 125, in view  
return self.dispatch(request, \*args, \*\*kwargs)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/rest\_framework/views.py”, line 509, in dispatch  
response = self.handle\_exception(exc)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/rest\_framework/views.py”, line 469, in handle\_exception  
self.raise\_uncaught\_exception(exc)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/rest\_framework/views.py”, line 480, in raise\_uncaught\_exception  
raise exc  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/rest\_framework/views.py”, line 506, in dispatch  
response = handler(request, \*args, \*\*kwargs)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/rest\_framework/mixins.py”, line 18, in create  
serializer.is\_valid(raise\_exception=True)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/rest\_framework/serializers.py”, line 227, in is\_valid  
self.\_validated\_data = self.run\_validation(self.initial\_data)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/rest\_framework/serializers.py”, line 426, in run\_validation  
value = self.to\_internal\_value(data)  
File “/Users/rogerlooser/.local/share/virtualenvs/storefront-djBK3ZAE/lib/python3.9/site-packages/rest\_framework/serializers.py”, line 485, in to\_internal\_value  
validated\_value = validate\_method(validated\_value)  
File “/Users/rogerlooser/Documents/Privat/Schule/Python/storefront/store/serializers.py”, line 73, in validate\_product\_id  
if not Product.objects.filter(pk=value).exist():  
AttributeError: ‘QuerySet’ object has no attribute ‘exist’  
[29/May/2023 19:57:35] “POST /store/carts/f9532386-9ada-4638-a672-a206af143cd3/items/ HTTP/1.1” 500 123109

**If I take the line code where the mistake is shown please see below:**

class AddCartItemSerializer(serializers.ModelSerializer):  
product\_id = serializers.IntegerField()

```
def validate_product_id(self, value):
    if not Product.objects.filter(pk=value).exist():
        raise serializers.ValidationError('No product with the given ID was found')
    return value

```

Maybe somebody has some hints how I solve it.  
Thanks  
Roger

---

<div class="post-metadata">

**Author:** ![BlotCoo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/blotcoo/32/5976_2.png) [@BlotCoo](https://forum.codewithmosh.com/u/BlotCoo)\
**Post date:** [May 29, 2023, 11:46pm UTC](https://forum.codewithmosh.com/t/6-creating-order-items-failure-by-adding-items-into-the-cart/20520/2 "2023-05-29T23:46:20Z")

</div>

I think it should be `exists()`, not `exist()`
