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
d6c45659
authored
Oct 19, 2010
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The abstraction we needed already exists.
parent
f759697f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
taggit/models.py
+1
-0
taggit/tests/models.py
+5
-4
No files found.
taggit/models.py
View file @
d6c45659
...
@@ -32,6 +32,7 @@ class TagBase(models.Model):
...
@@ -32,6 +32,7 @@ class TagBase(models.Model):
trans_kwargs
=
{}
trans_kwargs
=
{}
i
=
0
i
=
0
while
True
:
while
True
:
i
+=
1
try
:
try
:
sid
=
transaction
.
savepoint
(
**
trans_kwargs
)
sid
=
transaction
.
savepoint
(
**
trans_kwargs
)
res
=
super
(
TagBase
,
self
)
.
save
(
*
args
,
**
kwargs
)
res
=
super
(
TagBase
,
self
)
.
save
(
*
args
,
**
kwargs
)
...
...
taggit/tests/models.py
View file @
d6c45659
...
@@ -123,7 +123,8 @@ class ArticleTag(Tag):
...
@@ -123,7 +123,8 @@ class ArticleTag(Tag):
proxy
=
True
proxy
=
True
def
slugify
(
self
,
tag
,
i
=
None
):
def
slugify
(
self
,
tag
,
i
=
None
):
slug
=
"category-
%
s"
%
tag
slug
=
"category-
%
s"
%
tag
.
lower
()
if
i
is
not
None
:
if
i
is
not
None
:
slug
+=
"-
%
d"
%
i
slug
+=
"-
%
d"
%
i
return
slug
return
slug
...
@@ -132,9 +133,9 @@ class ArticleTaggedItem(TaggedItem):
...
@@ -132,9 +133,9 @@ class ArticleTaggedItem(TaggedItem):
class
Meta
:
class
Meta
:
proxy
=
True
proxy
=
True
# Basically we want to overide the tag ForeignKey to point at the proxy
@classmethod
# inherited ArticleTag so we can get the right slugify, unfortunately I
def
tag_model
(
self
):
# can't seem to figure out how to do this, so we're on hold ATM.
return
ArticleTag
class
Article
(
models
.
Model
):
class
Article
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
)
title
=
models
.
CharField
(
max_length
=
100
)
...
...
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