Re: how to get only the 'title' attribute value from following data in django

2021-04-22 Thread Derek
I'd use: querye = Product.objects.filter(id=sell_id).values('title') title = querye[0]['title'] # get the title for the first Product But if you're sure there is one (and only one) product matching the 'sell_id', you can use: querye = Product.objects.get(id=sell_id) title = querye.title HTH

how to get only the 'title' attribute value from following data in django

2021-04-22 Thread Bhathiya Amarasinghe
This is the views.py I want to get 'title' attribute from the serialize data views.py class CalculatView(views.APIView): query = CartProduct.objects.latest('id') serializer = CartProductSerializer(query) choose_product = serializer.data.get('product') [sell_id] = choose_product querye =