Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-taggit
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
56e1227f
authored
Jan 12, 2010
by
Rob Hudson
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'alex/master'
parents
aa961dd9
345554b9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
8 deletions
+4
-8
README.txt
+1
-1
taggit/managers.py
+2
-4
taggit/tests/tests.py
+1
-3
No files found.
README.txt
View file @
56e1227f
...
...
@@ -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>]
...
...
taggit/managers.py
View file @
56e1227f
...
...
@@ -48,10 +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
==
"exact"
:
value
=
[
value
]
if
lookup_type
!=
"in"
:
raise
ValueError
(
"You can't do lookups other than
\"
in
\"
on Tags"
)
if
all
(
isinstance
(
v
,
Tag
)
for
v
in
value
):
qs
=
TaggedItem
.
objects
.
filter
(
tag__in
=
value
)
elif
all
(
isinstance
(
v
,
basestring
)
for
v
in
value
):
...
...
taggit/tests/tests.py
View file @
56e1227f
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment