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
fdcce8d0
authored
Dec 08, 2009
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
You can add tag objects.
parent
2172cc0b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletions
+5
-1
taggit/managers.py
+2
-1
taggit/tests/tests.py
+3
-0
No files found.
taggit/managers.py
View file @
fdcce8d0
...
...
@@ -105,7 +105,8 @@ class _TaggableManager(models.Manager):
@require_instance_manager
def
add
(
self
,
*
tags
):
for
tag
in
tags
:
tag
,
_
=
Tag
.
objects
.
get_or_create
(
name
=
tag
)
if
not
isinstance
(
tag
,
Tag
):
tag
,
_
=
Tag
.
objects
.
get_or_create
(
name
=
tag
)
TaggedItem
.
objects
.
create
(
object_id
=
self
.
object_id
,
content_type
=
ContentType
.
objects
.
get_for_model
(
self
.
model
),
tag
=
tag
)
...
...
taggit/tests/tests.py
View file @
fdcce8d0
...
...
@@ -34,6 +34,9 @@ class AddTagTestCase(BaseTaggingTest):
apple
.
tags
.
remove
(
'green'
)
self
.
assert_tags_equal
(
apple
.
tags
.
all
(),
[
'red'
])
self
.
assert_tags_equal
(
Food
.
tags
.
all
(),
[
'green'
,
'red'
])
tag
=
Tag
.
objects
.
create
(
name
=
"delicious"
)
apple
.
tags
.
add
(
tag
)
self
.
assert_tags_equal
(
apple
.
tags
.
all
(),
[
"red"
,
"delicious"
])
class
LookupByTagTestCase
(
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