Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TagManager.usage_for_model returns list instead of queryset #44

Open
GoogleCodeExporter opened this issue Mar 26, 2015 · 8 comments
Open

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

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

  • Changed state: Chatting
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

Attachments:

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Any update on this please? This will be a very useful feature.

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

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant