Commit 386c06af by Alex Gaynor

Fixed #4. Removed support for lookups using the (default) lookup, you must use…

Fixed #4.  Removed support for lookups using the  (default) lookup, you must use __in, since using exact only works under SQLite.
parent 805389ac
......@@ -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>]
......
......@@ -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):
......
......@@ -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):
......
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