Commit 543471cd by Alex Gaynor

Merge remote branch 'origin/master'

parents 377bb478 18566407
from django.contrib.contenttypes.generic import GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models.fields.related import ManyToManyRel
from django.db.models.fields.related import ManyToManyRel, RelatedField
from django.db.models.related import RelatedObject
from django.utils.translation import ugettext_lazy as _
from taggit.forms import TagField
from taggit.models import Tag, TaggedItem, GenericTaggedItemBase
from taggit.models import TaggedItem, GenericTaggedItemBase
from taggit.utils import require_instance_manager
......@@ -35,7 +35,7 @@ class TaggableRel(ManyToManyRel):
self.through = None
class TaggableManager(object):
class TaggableManager(RelatedField):
def __init__(self, verbose_name=_("Tags"), through=None):
self.use_gfk = through is None or issubclass(through, GenericTaggedItemBase)
self.through = through or TaggedItem
......@@ -72,12 +72,6 @@ class TaggableManager(object):
def save_form_data(self, instance, value):
getattr(instance, self.name).set(*value)
def get_prep_lookup(self, lookup_type, value):
return models.Field().get_prep_lookup(lookup_type, value)
def get_db_prep_lookup(self, *args, **kwargs):
return models.Field().get_db_prep_lookup(*args, **kwargs)
def formfield(self, form_class=TagField, **kwargs):
defaults = {
"label": _("Tags"),
......
......@@ -146,7 +146,7 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
)
tag = self.tag_model.objects.get(name="woof")
self.assertEqual(list(self.pet_model.objects.filter(tags__name__in=[tag])), [dog])
self.assertEqual(list(self.pet_model.objects.filter(tags__in=[tag])), [dog])
cat = self.housepet_model.objects.create(name="cat", trained=True)
cat.tags.add("fuzzy")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment