from philo.models import Attribute
from philo.models.fields.entities import ForeignKeyAttribute, ManyToManyAttribute
from philo.admin.forms.attributes import AttributeForm, AttributeInlineFormSet
-from philo.admin.widgets import TagFilteredSelectMultiple
from philo.forms.entities import EntityForm, proxy_fields_for_entity_model
def backwards(self, orm):
"Write your backwards methods here."
- import pdb
- pdb.set_trace()
BlogEntry = orm['penfield.BlogEntry']
NewsletterArticle = orm['penfield.NewsletterArticle']
Tag = orm['philo.Tag']
TaggitTag = orm['taggit.Tag']
TaggedItem = orm['taggit.TaggedItem']
+ ContentType = orm['contenttypes.contenttype']
+
+ entry_ct = ContentType.objects.get(app_label="penfield", model="blogentry")
+ article_ct = ContentType.objects.get(app_label="penfield", model="newsletterarticle")
for entry in BlogEntry.objects.all():
- tag_slugs = list(TaggitTag.objects.filter(taggit_taggeditem_items__content_object=entry).values_list('slug', flat=True)).distinct()
+ tag_slugs = list(TaggitTag.objects.filter(taggit_taggeditem_items__content_type=entry_ct, taggit_taggeditem_items__object_id=entry.pk).values_list('slug', flat=True).distinct())
entry.tags = Tag.objects.filter(slug__in=tag_slugs)
entry.save()
for article in NewsletterArticle.objects.all():
- tag_slugs = list(TaggitTag.objects.filter(taggit_taggeditem_items__content_object=article).values_list('slug', flat=True)).distinct()
+ tag_slugs = list(TaggitTag.objects.filter(taggit_taggeditem_items__content_type=article_ct, taggit_taggeditem_items__object_id=article.pk).values_list('slug', flat=True).distinct())
article.tags = Tag.objects.filter(slug__in=tag_slugs)
article.save()
}
}
- complete_apps = ['penfield']
+ complete_apps = ['penfield', 'taggit']
+ symmetrical = True
from django.db import models
from django.http import Http404, HttpResponse
from taggit.managers import TaggableManager
+from taggit.models import Tag, TaggedItem
from philo.contrib.winer.models import FeedView
from philo.exceptions import ViewCanNotProvideSubpath
@property
def entry_tags(self):
"""Returns a :class:`QuerySet` of :class:`.Tag`\ s that are used on any entries in this blog."""
- return Tag.objects.filter(blogentries__blog=self).distinct()
+ entry_pks = list(self.entries.values_list('pk', flat=True))
+ kwargs = {
+ '%s__object_id__in' % TaggedItem.tag_relname(): entry_pks
+ }
+ return TaggedItem.tags_for(BlogEntry).filter(**kwargs)
@property
def entry_dates(self):