How to access value in QuerySet Django

Question:

I am creating a simple Pizza Delivery website and trying to add an option to choose a topping. When I want to print Ingredients it returns QuerySet and Values in it separated by a comma. Is there any option how can I get values based on their variable names (ex. ingredients.all[0].toppingName -> cheese) or is there any methods which allows to get values separately. Of course, kludge with .split works but it is awful

enter image description here
Models

UPD:

As for admin panel the provided solution worked. But it does not work in html template, so I found this code. Maybe it will useful for somebody.

enter image description here

Asked By: Entl_

||

Answers:

In Django, if you want to get only a specific column value you can use

Model.objects.all().values('column_name')

You can also filter the queryset and get values as

Model.objects.filter(condition).values('column_name')
Answered By: Manoj Kamble
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.