I had this proble too. Heres how i solved it.

First i had a model method:

 def get_wordcount(self):
        return len(self.content.split())

(content is a TextField)

Then in my template i used it like this:

{{ object.content|truncatewords:60 }}
    {% load base_utils %}
                {% ifgreaterthan object.get_wordcount 60 %}
                         <a href="/news/{{ object.id }}">read more</a></p>
                {% endifgreaterthan %}

You'll also need to get the ifgreaterthan custom template tag from
here:
https://svn.nrcfosshelpline.in/public/helpline/trunk/web/templatetags/base_utils.py
(you'll need to edit it a bit)

Hope it helps

Sam Morrison


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to