Am working on an Ecommerce website using django. My problem is that some products name are longer that the other, which makes the product display look odd.
Question: How do I limit the length of product name and add dots to show that it continue
Example:
product_name = "Men Suede Loafers Moccasins Shoes -Black"
will look like
product_name = "Men Suede Loafers Mocca...."
You can make use of the |truncatechars template filter [Django-doc]:
{{ product_name|truncatechars:23 }}
While you thus store the product_name as full text, it is rendered for the first 23 characters, and then followed by an ellipsis (…).
You can also add a tooltip that shows the text in full, for example:
<p title="{{ product_name }}">{{ product_name|truncatechars:23 }}</p>
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