kitaindia / django-tagging

Automatically exported from code.google.com/p/django-tagging
Other
0 stars 0 forks source link

TagManager.usage_for_model returns list instead of queryset #44

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
It would be nice if TagManager.usage_for_model returned a queryset instead
of a list so that code such as

Tag.objects.usage_for_model(Item, counts=True).order_by('-count') 

would still work.  This used to work in previous revisions.

Original issue reported on code.google.com by mr.bald...@gmail.com on 7 Jun 2007 at 12:07

GoogleCodeExporter commented 8 years ago
Yes, it would be great to have this kind of behaviour for the objects managers.

In my case, i wish to have paginated tag clouds and cannot use the generic
object_list for that purpose.

Original comment by samuel.a...@gmail.com on 18 Jun 2007 at 8:40

GoogleCodeExporter commented 8 years ago
Do you know of any half-decent way to get the necessary GROUP BY statements 
into the
ORM in order to achieve this?

If there isn't one, I think we'll have to hold out for the QuerySet refactor 
landing
in trunk.

The docstring on `TaggedItemManager.get_intersection_by_model` speaks for a few
places at the moment :)

Original comment by jonathan.buchanan on 21 Aug 2007 at 12:51

GoogleCodeExporter commented 8 years ago
I've written a patch that updates `usage_for_*` to return a queryset object. I 
wasn't trying to add this feature, 
just make `usage_for_queryset` work, as it seemed to be returning a list of 
tags for ALL objects of the same 
type as the passed in queryset, not only objects in the passed in queryset.

Original comment by real.hu...@mrmachine.net on 8 Apr 2009 at 5:32

Attachments:

GoogleCodeExporter commented 8 years ago
I really need this feature for a project I'm working on... specifically the 
example:

Tag.objects.usage_for_model(Item, counts=True).order_by('-count')

Can anyone suggest how I can achieve the same result in the meantime?

Original comment by litt.fir...@gmail.com on 10 Sep 2009 at 10:55

GoogleCodeExporter commented 8 years ago
Any updates on this issue?  I'm wondering why `usage_for_model` returns a list 
in the first place, rather than a 
queryset...

Original comment by kyle.fox on 20 Oct 2009 at 3:05

GoogleCodeExporter commented 8 years ago
For anyone interested in a solution to order the tags by count in the 
templates: the
built in django {% regroup %} tag can be used quite effectively.

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup

Scroll down, just above the next section (spaceless tag), and you will see how 
to
order the set. I ended up with this:

    {% regroup tag_list|dictsort:"count" by count as sorted_tags %}
    <div class="portlet" id="tag_list">
        {% for tags in sorted_tags %}
        <h3>Tags</h3>
        <ul>
            {% for tag in tags.list %}
            <li><a href="#">{{ tag }} ({{ tag.count }})</a></li>
            {% endfor %}
        </ul>
        {% endfor %}
    </div>

Original comment by litt.fir...@gmail.com on 23 Oct 2009 at 6:45

GoogleCodeExporter commented 8 years ago
Any update on this please? This will be a very useful feature.

Original comment by madhusudancs on 16 Jan 2011 at 12:14

GoogleCodeExporter commented 8 years ago
My patch above still works, but it won't apply cleanly to trunk anymore, thanks 
to r172.

I've attached an updated patch that applies cleanly to 0.3.1.

Disappointed that this hasn't been resolved in over 2 years now. This looks 
like abandonware, with all the issues continuing to pile up.

Original comment by real.hu...@mrmachine.net on 19 Jul 2011 at 12:46

Attachments: