1
One option is to use objects.get()
:
item_name = Icecream.objects.get(pk=icecream_id).name
Or, if you still want to use filter()
, but don’t want to see dictionary with name
key, use values_list()
with flat=True
:
item_name = Icecream.objects.get(pk=icecream_id).values_list('name', flat=True)
1
From the next section down in the docs:
item_name = Icecream.objects.filter(pk=icecream_id).values_list('name')
- [Answered ]-JQuery/Django Syntax error
- [Answered ]-Bug in Django CacheMachine ignores saving of Model?
- [Answered ]-Getting File from form field in Django
Source:stackexchange.com