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
46a4e80a
authored
Sep 26, 2009
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a most common method to tags managers
parent
76c8a84f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
taggit/managers.py
+5
-0
taggit/tests/tests.py
+2
-0
No files found.
taggit/managers.py
View file @
46a4e80a
...
...
@@ -51,3 +51,8 @@ class _TaggableManager(models.Manager):
def
clear
(
self
):
TaggedItem
.
objects
.
filter
(
object_id
=
self
.
object_id
,
content_type
=
ContentType
.
objects
.
get_for_model
(
self
.
model
))
.
delete
()
def
most_common
(
self
):
return
self
.
get_query_set
()
.
annotate
(
num_times
=
models
.
Count
(
'items'
)
)
.
order_by
(
'-num_times'
)
taggit/tests/tests.py
View file @
46a4e80a
...
...
@@ -27,6 +27,8 @@ class AddTagTestCase(BaseTaggingTest):
self
.
assert_tags_equal
(
apple
.
tags
.
all
(),
[
'green'
,
'red'
])
self
.
assert_tags_equal
(
Food
.
tags
.
all
(),
[
'green'
,
'red'
])
self
.
assert_tags_equal
(
Food
.
tags
.
most_common
(),
[
'green'
,
'red'
])
apple
.
tags
.
remove
(
'green'
)
self
.
assert_tags_equal
(
apple
.
tags
.
all
(),
[
'red'
])
self
.
assert_tags_equal
(
Food
.
tags
.
all
(),
[
'green'
,
'red'
])
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