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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
42b5b22f
authored
Sep 19, 2010
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly cleaner code.
parent
5eebab39
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
taggit/managers.py
+6
-4
No files found.
taggit/managers.py
View file @
42b5b22f
...
@@ -52,12 +52,12 @@ class TaggableManager(RelatedField):
...
@@ -52,12 +52,12 @@ class TaggableManager(RelatedField):
models
.
Field
.
creation_counter
+=
1
models
.
Field
.
creation_counter
+=
1
def
__get__
(
self
,
instance
,
model
):
def
__get__
(
self
,
instance
,
model
):
manager
=
_TaggableManager
(
through
=
self
.
through
)
manager
.
model
=
model
if
instance
is
not
None
and
instance
.
pk
is
None
:
if
instance
is
not
None
and
instance
.
pk
is
None
:
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
.
instance
=
instance
manager
=
_TaggableManager
(
through
=
self
.
through
,
model
=
model
,
instance
=
instance
)
return
manager
return
manager
def
contribute_to_class
(
self
,
cls
,
name
):
def
contribute_to_class
(
self
,
cls
,
name
):
...
@@ -113,8 +113,10 @@ class TaggableManager(RelatedField):
...
@@ -113,8 +113,10 @@ class TaggableManager(RelatedField):
class
_TaggableManager
(
models
.
Manager
):
class
_TaggableManager
(
models
.
Manager
):
def
__init__
(
self
,
through
):
def
__init__
(
self
,
through
,
model
,
instance
):
self
.
through
=
through
self
.
through
=
through
self
.
model
=
model
self
.
instance
=
instance
def
get_query_set
(
self
):
def
get_query_set
(
self
):
return
self
.
through
.
tags_for
(
self
.
model
,
self
.
instance
)
return
self
.
through
.
tags_for
(
self
.
model
,
self
.
instance
)
...
...
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