wrong tag list

34 views
Skip to first unread message

burak.k...@gmail.com

unread,
Aug 20, 2013, 7:27:15 PM8/20/13
to django...@googlegroups.com
Hi,
I have a Work model with Category Foreign Key.  I am doing  -->  

drawingTags = Tag.objects.filter(Q(work__category__slug_en = 'drawing') |

                                                  Q(work__category__slug_en = 'illustration') |

                                                  Q(work__category__slug_en = 'sketch') |

                                                  Q(work__category__slug_en = 'storyboard'))


I get also the tags that do not belong to drawings ?  Am i doing smt wrong ?

burak.k...@gmail.com

unread,
Aug 21, 2013, 5:52:21 PM8/21/13
to django...@googlegroups.com, burak.k...@gmail.com
A little more info for the problem:

I have a blog application  with an entry model it has a 'TaggableManager field' named tags.
And also my web application's work model has a 'TaggableManager field' named tags.

And when i want the tags of the works that are categorized under 'drawings'  taggit adds the entry tags to the result... What can be the problem?

21 Ağustos 2013 Çarşamba 02:27:15 UTC+3 tarihinde burak.k...@gmail.com yazdı:

burak.k...@gmail.com

unread,
Aug 21, 2013, 7:07:51 PM8/21/13
to django...@googlegroups.com, burak.k...@gmail.com
Sorry i have forgot to tell that my work model's category fk  field is inheriting from an abstract base class...

22 Ağustos 2013 Perşembe 00:52:21 UTC+3 tarihinde burak.k...@gmail.com yazdı:

burak.k...@gmail.com

unread,
Aug 22, 2013, 5:34:46 AM8/22/13
to django...@googlegroups.com, burak.k...@gmail.com
Solution :

from django.contrib.contenttypes.models import ContentType  

contentType = ContentType.objects.get_for_model(Work)
drawingTags =Tag.objects.filter(taggit_taggeditem_items__content_type=contentType, 
                                        work__in = drawings ).distinct()


Reply all
Reply to author
Forward
0 new messages