From 386c06af6db3173b735b23a486526f8971cdc8f6 Mon Sep 17 00:00:00 2001 From: Alex Gaynor <alex.gaynor@gmail.com> Date: Wed, 13 Jan 2010 00:12:40 -0600 Subject: [PATCH] Fixed #4. Removed support for lookups using the (default) lookup, you must use __in, since using exact only works under SQLite. --- README.txt | 2 +- taggit/managers.py | 4 ++-- taggit/tests/tests.py | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.txt b/README.txt index 185e50a..c310e33 100644 --- a/README.txt +++ b/README.txt @@ -22,7 +22,7 @@ Then you can use the API like so: [<Tag: red>, <Tag: green>, <Tag: delicious>] >>> apple.tags.remove("green") [<Tag: red>, <Tag: delicious>] - >>> Food.objects.filter(tags="red") + >>> Food.objects.filter(tags__in=["red"]) [<Food: apple>, <Food: cherry>] diff --git a/taggit/managers.py b/taggit/managers.py index 8fd70b5..54fdf6a 100644 --- a/taggit/managers.py +++ b/taggit/managers.py @@ -48,8 +48,8 @@ class TaggableManager(object): getattr(instance, self.name).set(*value) def get_db_prep_lookup(self, lookup_type, value): - if lookup_type not in ("in", "exact"): - raise ValueError("You can't do lookups other than \"in\" and \"exact\" on Tags") + if lookup_type != "in": + raise ValueError("You can't do lookups other than \"in\" on Tags") if lookup_type == "exact": value = [value] if all(isinstance(v, Tag) for v in value): diff --git a/taggit/tests/tests.py b/taggit/tests/tests.py index 886bd8d..7cb22ac 100644 --- a/taggit/tests/tests.py +++ b/taggit/tests/tests.py @@ -59,10 +59,8 @@ class LookupByTagTestCase(BaseTaggingTest): dog.tags.add("woof", "red") self.assertEqual(list(Food.objects.filter(tags__in=["red"]).distinct()), [apple]) - self.assertEqual(list(Food.objects.filter(tags="red").distinct()), [apple]) - tag = Tag.objects.get(name="woof") - self.assertEqual(list(Pet.objects.filter(tags=tag)), [dog]) + self.assertEqual(list(Pet.objects.filter(tags__in=[tag])), [dog]) class TaggableFormTestCase(BaseTaggingTest): -- libgit2 0.26.0