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.

You don't need to write any more complicated views in order to access
an object's methods. Using generic views, you should be able to access
it as a member of the "object" variable on an object detail page. Try
something like this:

{% if object.was_published_today %}
  Today's poll
{% else %}
  Not today's poll
{% endif %}

On a list page, you are probably already iterating over the
"object_list" variable -- you should be able to access the
was_published_today method in a similar manner, for each element of
that set.


Ian Clelland
<[EMAIL PROTECTED]>

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