I am tried to create a slice in django template and get an attribute. How can i do in django template something like this:
python code:
somelist[1].name
please help
If you are accessing a single element of a list, you don't need the slice
filter, just use the dot notation.
{{ somelist.1.name }}
See the docs for more info.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.