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
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 =
2 matches
Mail list logo