List Info

Thread: Returning a list of entries associated with a tag (using django-tagging)




Returning a list of entries associated with a tag (using django-tagging)
country flaguser name
United States
2007-05-25 11:56:44
I'm trying to write a view to return a list of blog entries
associated
with a specific tag (using the django-tagging app).

Can I do this with a generic view? I've managed to use that
for
returning a list of all tags.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Returning a list of entries associated with a tag (using django-tagging)
country flaguser name
United States
2007-05-25 18:34:39
Hi,

you could use the related_for_model function in your view:

tag = Tag.objects.get(pk=1)
assoc_entries = Tag.objects.related_for_model(tag,
BlogEntry)

On 25 Mai, 18:56, "patrickbee...gmail.com"
<patrickbee...gmail.com>
wrote:
> I'm trying to write a view to return a list of blog
entries associated
> with a specific tag (using the django-tagging app).
>
> Can I do this with a generic view? I've managed to use
that for
> returning a list of all tags.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Returning a list of entries associated with a tag (using django-tagging)
country flaguser name
United States
2007-05-30 07:41:45
On May 25, 5:56 pm, "patrickbee...gmail.com"
<patrickbee...gmail.com> wrote:
> I'm trying to write a view to return a list of blog
entries associated
> with a specific tag (using the django-tagging app).

You can do the following to get a BlogEntry QuerySet for
the
appropriate entries:

    TaggedItem.objects.get_by_model(BlogEntry, some_tag)

As of the 0.1 release, some_tag can be a Tag instance, a Tag
QuerySet,
the name of a tag, or the id of a tag.

> Can I do this with a generic view? I've managed to use
that for
> returning a list of all tags.

D'oh, why didn't I think of that? Expect to see a generic
view for
this appearing in SVN sometime soon. Off the top of my head,
it should
be a simple wrapper around the object_list view.

Jonathan.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )