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
c92f7473
authored
Sep 23, 2010
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #42. Putting a taggable manager on an abstract model now works.
parent
32bc5b00
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
+29
-2
taggit/managers.py
+1
-1
taggit/tests/models.py
+12
-0
taggit/tests/tests.py
+16
-1
No files found.
taggit/managers.py
View file @
c92f7473
...
...
@@ -65,7 +65,7 @@ class TaggableManager(RelatedField):
self
.
model
=
cls
cls
.
_meta
.
add_field
(
self
)
setattr
(
cls
,
name
,
self
)
if
self
.
use_gfk
:
if
self
.
use_gfk
and
not
cls
.
_meta
.
abstract
:
tagged_items
=
GenericRelation
(
self
.
through
)
tagged_items
.
contribute_to_class
(
cls
,
"tagged_items"
)
...
...
taggit/tests/models.py
View file @
c92f7473
...
...
@@ -103,3 +103,15 @@ class OfficialPet(models.Model):
class
OfficialHousePet
(
OfficialPet
):
trained
=
models
.
BooleanField
()
class
Media
(
models
.
Model
):
tags
=
TaggableManager
()
class
Meta
:
abstract
=
True
class
Photo
(
Media
):
pass
class
Movie
(
Media
):
pass
taggit/tests/tests.py
View file @
c92f7473
...
...
@@ -8,7 +8,7 @@ from taggit.tests.forms import (FoodForm, DirectFoodForm, CustomPKFoodForm,
from
taggit.tests.models
import
(
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
DirectHousePet
,
TaggedPet
,
CustomPKFood
,
CustomPKPet
,
CustomPKHousePet
,
TaggedCustomPKPet
,
OfficialFood
,
OfficialPet
,
OfficialHousePet
,
OfficialThroughModel
,
OfficialTag
)
OfficialThroughModel
,
OfficialTag
,
Photo
,
Movie
)
from
taggit.utils
import
parse_tags
,
edit_string_for_tags
...
...
@@ -212,6 +212,21 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
unicode
(
self
.
taggeditem_model
.
objects
.
all
()[
0
]),
"ross tagged with president"
)
def
test_abstract_subclasses
(
self
):
p
=
Photo
.
objects
.
create
()
p
.
tags
.
add
(
"outdoors"
,
"pretty"
)
self
.
assert_tags_equal
(
p
.
tags
.
all
(),
[
"outdoors"
,
"pretty"
]
)
m
=
Movie
.
objects
.
create
()
m
.
tags
.
add
(
"hd"
)
self
.
assert_tags_equal
(
m
.
tags
.
all
(),
[
"hd"
],
)
class
TaggableManagerDirectTestCase
(
TaggableManagerTestCase
):
...
...
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