aboutsummaryrefslogtreecommitdiff
path: root/tagging/managers.py
diff options
context:
space:
mode:
authorJonas Genannt <genannt@debian.org>2015-11-15 22:26:06 +0100
committerJonas Genannt <genannt@debian.org>2015-11-15 22:26:06 +0100
commitd65aa3c3c146b12548a54c894060bce9a8715ad2 (patch)
tree293607c424ec0b1d41e2aefaf26989a7adbd3e04 /tagging/managers.py
parent29425a36c920e9b54e5860429ef3e3ce639fb155 (diff)
downloadpython-django-tagging-d65aa3c3c146b12548a54c894060bce9a8715ad2.tar
python-django-tagging-d65aa3c3c146b12548a54c894060bce9a8715ad2.tar.gz
Imported Upstream version 0.4upstream/0.4
Diffstat (limited to 'tagging/managers.py')
-rw-r--r--tagging/managers.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/tagging/managers.py b/tagging/managers.py
index 02cd1c2..d85c260 100644
--- a/tagging/managers.py
+++ b/tagging/managers.py
@@ -1,17 +1,18 @@
"""
-Custom managers for Django models registered with the tagging
-application.
+Custom managers for tagging.
"""
-from django.contrib.contenttypes.models import ContentType
from django.db import models
+from django.contrib.contenttypes.models import ContentType
+
+from tagging.models import Tag
+from tagging.models import TaggedItem
-from tagging.models import Tag, TaggedItem
class ModelTagManager(models.Manager):
"""
A manager for retrieving tags for a particular model.
"""
- def get_query_set(self):
+ def get_queryset(self):
ctype = ContentType.objects.get_for_model(self.model)
return Tag.objects.filter(
items__content_type__pk=ctype.pk).distinct()
@@ -25,6 +26,7 @@ class ModelTagManager(models.Manager):
def usage(self, *args, **kwargs):
return Tag.objects.usage_for_model(self.model, *args, **kwargs)
+
class ModelTaggedItemManager(models.Manager):
"""
A manager for retrieving model instances based on their tags.
@@ -47,6 +49,7 @@ class ModelTaggedItemManager(models.Manager):
else:
return TaggedItem.objects.get_union_by_model(queryset, tags)
+
class TagDescriptor(object):
"""
A descriptor which provides access to a ``ModelTagManager`` for