X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/dfd584e3b136d770bf56569030d10712a8722569..4bb3e264dc9d9953c6a1ffcb0290a2ba0e0c094b:/apps/newtagging/models.py diff --git a/apps/newtagging/models.py b/apps/newtagging/models.py index 7e9936f30..694f5b868 100644 --- a/apps/newtagging/models.py +++ b/apps/newtagging/models.py @@ -71,7 +71,7 @@ class TagManager(models.Manager): if tag not in current_tags: self.intermediary_table_model._default_manager.create(tag=tag, content_object=obj) - tags_updated.send(sender=obj, affected_tags=tags_to_add + tags_for_removal) + tags_updated.send(sender=type(obj), instance=obj, affected_tags=tags_to_add + tags_for_removal) def remove_tag(self, obj, tag): """ @@ -179,7 +179,7 @@ class TaggedItemManager(models.Manager): if not tags: return queryset.none() # TODO: presumes reverse generic relation - return queryset.filter(tag_relations__tag__in=tags) + return queryset.filter(tag_relations__tag__in=tags).distinct() def get_related(self, obj, queryset_or_model): """ @@ -228,8 +228,8 @@ def create_intermediary_table_model(model): class TagMeta(ModelBase): "Metaclass for tag models (models inheriting from TagBase)." - def __new__(cls, name, bases, attrs): - model = super(TagMeta, cls).__new__(cls, name, bases, attrs) + def __new__(mcs, name, bases, attrs): + model = super(TagMeta, mcs).__new__(mcs, name, bases, attrs) if not model._meta.abstract: # Create an intermediary table and register custom managers for concrete models model.intermediary_table_model = create_intermediary_table_model(model)