*Sorry for confusing,my English is bad also.

The problem is django-voting is not provide templatetags to access vote for
particular object. Instead it provide templatetags to access only template
context variable (Correct me if I'm wrong). See bebow,

score_for_object
~~~~~~~~~~~~~~~~

Retrieves the total score for an object and the number of votes
it's received, storing them in a context variable which has ``score``
and ``num_votes`` properties.

Example usage::

 {% score_for_object widget as score %}

 {{ score.score }} point{{ score.score|pluralize }} after {{ score.num_votes
}} vote{{ score.num_votes|pluralize }}

In my case, I'm fine  if I  have something like this

{% load generic_content%}
{% load voting_tags %}
{% get_latest_objects blog.post 10 as latest_post %}

So, I can,

{% scores_for_objects **latest_post** as scores %}

{% for post in latest_post%}

{% dict_entry_for_item post from scores as vote %}
{{post}} has {{vote.score}}.
{% endfor %}

For my case,

{% for item in latest_item%}
... I cannot use dict_entry_for_item because each item doesn't has vote.
{% endfor %}

For now, my sulotion is, implement additional templatetag to allow retrival
vote of any model . For example,

{% get_latest_objects aggregate.item 10 as latest_items %}
{% for item in  latest_items %}
    {% ifequal item.content_type.model "post" %}
        {% score_by_pk blog.post item.object.pk as score%} {# my own
template tag#}
        {{ post }} has {{score.score}}
    {% endif %}
 {% endfor %}


Umm, it look complicate** and ugly?

Regards
 *


2008/4/27 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:

>
> What exactly is your problem? Is latest_items empty in the template?
>
> On Apr 26, 2:10 am, chatchai <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > I use a modified version ofhttp://jellyroll.googlecode.com/by adding
> > my own models into follow list (jellyrool.models.Item).  For example,
> >
> > Item.objects.follow_model(Post)
> >
> > After that, I added django-voting (http://django-
> > voting.googlecode.com/) to my application list.
> >
> > The problem is, at the index page. I want to list latest item. If
> > latest item is Post and it has Vote as well, I will show post and its
> > vote. I also use template_utils (http://django-template-
> > utils.googlecode.com/svn/trunk). My code look like this,
> >
> > {% load generic_content%}
> > {% load voting_tags %}
> > {% get_latest_objects aggregate.item 10 as latest_items %}
> >
> > I try to access voting for post in  latest_items and cannot find any
> > solution.
> >
> > Any idea is my appreciated.
> >
> > Thanks
> >
> > Chatchai
> >
>

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to