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
90fe33b7
authored
Dec 08, 2009
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow __exact lookups
parent
f64167b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
taggit/managers.py
+4
-2
taggit/tests/tests.py
+2
-0
No files found.
taggit/managers.py
View file @
90fe33b7
...
...
@@ -44,8 +44,10 @@ class TaggableManager(object):
pass
def
get_db_prep_lookup
(
self
,
lookup_type
,
value
):
if
lookup_type
!=
"in"
:
raise
ValueError
(
"You can't do lookups other than in on Tags"
)
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
]
qs
=
TaggedItem
.
objects
.
filter
(
tag__name__in
=
value
)
.
values_list
(
"pk"
,
flat
=
True
)
sql
,
params
=
qs
.
query
.
as_sql
()
return
QueryWrapper
((
"(
%
s)"
%
sql
),
params
)
...
...
taggit/tests/tests.py
View file @
90fe33b7
...
...
@@ -53,6 +53,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
])
class
TaggableFormTestCase
(
BaseTaggingTest
):
def
test_form
(
self
):
...
...
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