On 8/3/06, skullvulture <[EMAIL PROTECTED]> wrote:
> In the tutorial you create a custom method was_published_today.  How
> can you access it in the template?  I'm using generic views.  Do I have
> to write my own more complicated view to access it?  Thanks.

Since it's a property of the object, having the object in the
template's context is enough to enable access to it; for example, if
you were using the 'object_detail' generic view, the template would
have a variable called 'object'; you could then do, for example,

{% if object.was_published_today %}
...do stuff for a story published today...
{% else %}
...do stuff for an older story...
{% endif %}

Take note of the fact that, when using it in a template, you do *not*
use parentheses: it's 'object.was_published_today', *not*
'object.was_published_today()'.

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

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