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
8bd0380e
authored
Sep 07, 2010
by
Carl Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix queries using actual tag objects
parent
d04ba396
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
9 deletions
+3
-9
taggit/managers.py
+2
-8
taggit/tests/tests.py
+1
-1
No files found.
taggit/managers.py
View file @
8bd0380e
from
django.contrib.contenttypes.generic
import
GenericRelation
from
django.contrib.contenttypes.generic
import
GenericRelation
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.contenttypes.models
import
ContentType
from
django.db
import
models
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.db.models.related
import
RelatedObject
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
...
@@ -35,7 +35,7 @@ class TaggableRel(ManyToManyRel):
...
@@ -35,7 +35,7 @@ class TaggableRel(ManyToManyRel):
self
.
through
=
None
self
.
through
=
None
class
TaggableManager
(
object
):
class
TaggableManager
(
RelatedField
):
def
__init__
(
self
,
verbose_name
=
_
(
"Tags"
),
through
=
None
):
def
__init__
(
self
,
verbose_name
=
_
(
"Tags"
),
through
=
None
):
self
.
use_gfk
=
through
is
None
or
issubclass
(
through
,
GenericTaggedItemBase
)
self
.
use_gfk
=
through
is
None
or
issubclass
(
through
,
GenericTaggedItemBase
)
self
.
through
=
through
or
TaggedItem
self
.
through
=
through
or
TaggedItem
...
@@ -72,12 +72,6 @@ class TaggableManager(object):
...
@@ -72,12 +72,6 @@ class TaggableManager(object):
def
save_form_data
(
self
,
instance
,
value
):
def
save_form_data
(
self
,
instance
,
value
):
getattr
(
instance
,
self
.
name
)
.
set
(
*
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
):
def
formfield
(
self
,
form_class
=
TagField
,
**
kwargs
):
defaults
=
{
defaults
=
{
"label"
:
_
(
"Tags"
),
"label"
:
_
(
"Tags"
),
...
...
taggit/tests/tests.py
View file @
8bd0380e
...
@@ -146,7 +146,7 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
...
@@ -146,7 +146,7 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
)
)
tag
=
self
.
tag_model
.
objects
.
get
(
name
=
"woof"
)
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
=
self
.
housepet_model
.
objects
.
create
(
name
=
"cat"
,
trained
=
True
)
cat
.
tags
.
add
(
"fuzzy"
)
cat
.
tags
.
add
(
"fuzzy"
)
...
...
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