Thursday, April 22, 2021

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


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 = Product.objects.filter(id = sell_id) 
 serializere = ProductSerializers(querye, many=True) 
 choosee = serializere.data 

  print(choosee)

Output : 

[OrderedDict([('id', 2), ('title', 'Frock'), ('date', '2021-04-22'), ('image', '/media/products/kids2.jpg'), ('marcket_price', 1.2), ('selling_price', 1.2), ('description', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), ('category', OrderedDict([('id', 2), ('title', 'Fashion'), ('date', '2021-04-22')])), ('seller', OrderedDict([('id', 2), ('seller_name', 'CIB - Piliyandala'), ('lat', 6.8018), ('lng', 79.9227), ('date', '2021-04-22')]))])]


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d1dba65a-6f05-4ea4-978a-900ddcc649d2n%40googlegroups.com.

No comments:

Post a Comment