Gaurav Gaurav - 1 year ago 67
CSS Question

Want to display the first character of word in django templates

I want to display first character of user in django templates.
I want to make a image of user first character like caption or avatar

like this


so i will get result like any name "Gaurav" or "Amit" but i just want first letter of them like "G" or "A"
So i can display it like image of first letter.

Answer Source

Solution with using templates tags(but for me the answer from @Kasra more preferable):

First letter:

{{ postone.user|make_list|first }}

Word without first:

{{ postone.user|make_list|slice:'1:'|join:'' }}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download