Reputation: 1169
In my template I am trying to check if a sentence is truncated. I have written a def in my model:
def read_more_needed(self):
from django.utils.text import Truncator
return Truncator(self.description).words(5, html=True, truncate=" ...")
end in my template i want to check like:
{% if model.read_more_needed %} <i class='fa fa-info'></i> {% endif %}
But Truncate does not returns false even it does not truncate the sentence... How can i achieve this?
Upvotes: 0
Views: 70
Reputation: 45595
Compare the result of truncation with the original text:
return self.description != Truncator(self.description).words(5, html=True,
truncate=" ...")
Upvotes: 1