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
d59d0e2f
authored
Nov 08, 2013
by
idan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
break some lines to match the 80 characters rule
parent
5dac3791
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
taggit/managers.py
+14
-4
No files found.
taggit/managers.py
View file @
d59d0e2f
...
@@ -83,7 +83,10 @@ class TaggableManager(RelatedField, Field):
...
@@ -83,7 +83,10 @@ class TaggableManager(RelatedField, Field):
raise
ValueError
(
"
%
s objects need to have a primary key value "
raise
ValueError
(
"
%
s objects need to have a primary key value "
"before you can access their tags."
%
model
.
__name__
)
"before you can access their tags."
%
model
.
__name__
)
manager
=
_TaggableManager
(
manager
=
_TaggableManager
(
through
=
self
.
through
,
model
=
model
,
instance
=
instance
,
prefetch_cache_name
=
self
.
name
through
=
self
.
through
,
model
=
model
,
instance
=
instance
,
prefetch_cache_name
=
self
.
name
)
)
return
manager
return
manager
...
@@ -336,15 +339,22 @@ class _TaggableManager(models.Manager):
...
@@ -336,15 +339,22 @@ class _TaggableManager(models.Manager):
from
django.db
import
connections
from
django.db
import
connections
db
=
self
.
_db
or
router
.
db_for_read
(
instance
.
__class__
,
instance
=
instance
)
db
=
self
.
_db
or
router
.
db_for_read
(
instance
.
__class__
,
instance
=
instance
)
fk
=
self
.
through
.
_meta
.
get_field
(
'object_id'
if
issubclass
(
self
.
through
,
GenericTaggedItemBase
)
else
'content_object'
)
fieldname
=
(
'object_id'
if
issubclass
(
self
.
through
,
GenericTaggedItemBase
)
else
'content_object'
)
fk
=
self
.
through
.
_meta
.
get_field
(
fieldname
)
query
=
{
query
=
{
'
%
s__
%
s__in'
%
(
self
.
through
.
tag_relname
(),
fk
.
name
)
:
set
(
obj
.
_get_pk_val
()
for
obj
in
instances
)
'
%
s__
%
s__in'
%
(
self
.
through
.
tag_relname
(),
fk
.
name
)
:
set
(
obj
.
_get_pk_val
()
for
obj
in
instances
)
}
}
join_table
=
self
.
through
.
_meta
.
db_table
join_table
=
self
.
through
.
_meta
.
db_table
source_col
=
fk
.
column
source_col
=
fk
.
column
connection
=
connections
[
db
]
connection
=
connections
[
db
]
qn
=
connection
.
ops
.
quote_name
qn
=
connection
.
ops
.
quote_name
qs
=
self
.
get_query_set
()
.
using
(
db
)
.
_next_is_sticky
()
.
filter
(
**
query
)
.
extra
(
select
=
{
'_prefetch_related_val'
:
'
%
s.
%
s'
%
(
qn
(
join_table
),
qn
(
source_col
))})
qs
=
self
.
get_query_set
()
.
using
(
db
)
.
_next_is_sticky
()
.
filter
(
**
query
)
.
extra
(
select
=
{
'_prefetch_related_val'
:
'
%
s.
%
s'
%
(
qn
(
join_table
),
qn
(
source_col
))
}
)
return
(
qs
,
return
(
qs
,
attrgetter
(
'_prefetch_related_val'
),
attrgetter
(
'_prefetch_related_val'
),
attrgetter
(
instance
.
_meta
.
pk
.
name
),
attrgetter
(
instance
.
_meta
.
pk
.
name
),
...
...
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