Reputation: 37846
I am stuck not knowing how to do this. i am using values()
method to get specific column from db but i dont know how to get the value of that column in queryset, i am getting after values()
something like this:
[columnname: value]
I want to get only the value. I think, in views.py i can get the value with object['column']
, but how do i get the value in template in django?
or what is the best way to do this?
Upvotes: 1
Views: 3972
Reputation: 473783
Use dot notation in Django templates:
{{ object.column }}
Dots have a special meaning in template rendering. A dot in a variable name signifies a lookup. Specifically, when the template system encounters a dot in a variable name, it tries the following lookups, in this order:
- Dictionary lookup. Example: foo["bar"]
- Attribute lookup. Example: foo.bar
- List-index lookup. Example: foo[bar]
Upvotes: 3