I want to create meta description on my website, in this moment i have this function for get product description :
{{ product.description|nl2br }}
Need edit this function for get only the first 150 characters for create meta description, is possible this in template ? or need create this function in views.py ?
jinja2 has a filter named truncate
, the documentation is here:
{{ "foo bar baz"|truncate(9) }}
-> "foo ..."
so, you can try this one:
{{ product.description | truncate(150) }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With