On 10/29/06, ringemup <[EMAIL PROTECTED]> wrote:
>
> Does that mean that this is really view logic?  It seems a shame to
> have to write a custom view function just to do something that's as
> simple and as display-related as that.  Is there any way to do this in
> the template?

You could split this into view logic; however, a better options is
probably to add a method to your model. Django templates can call any
method on an object that takes no arguments, so a simple 'is_long'
method on the object could be used to determine if any given object
has more that 75 words.

For example:

class Article(Model):
    ... (fields) ...
    def is_long(self):
        return ...(logic for a long article)...

Then in your template, if object_list is a list of articles:

{% for object in object_list %}
   {{ object.body }}
   {% if object.is_long %}
        ... link to 'read more'
   {% endif %}
{% endfor %}

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
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