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
b6b290b9
authored
Oct 19, 2010
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document the new slugify hook
parent
d6c45659
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
docs/custom_tagging.txt
+14
-2
No files found.
docs/custom_tagging.txt
View file @
b6b290b9
...
@@ -20,10 +20,10 @@ model named ``content_object``. Pass this intermediary model as the
...
@@ -20,10 +20,10 @@ model named ``content_object``. Pass this intermediary model as the
from taggit.managers import TaggableManager
from taggit.managers import TaggableManager
from taggit.models import TaggedItemBase
from taggit.models import TaggedItemBase
class TaggedFood(TaggedItemBase):
class TaggedFood(TaggedItemBase):
content_object = models.ForeignKey('Food')
content_object = models.ForeignKey('Food')
class Food(models.Model):
class Food(models.Model):
# ... fields here
# ... fields here
...
@@ -44,3 +44,15 @@ Class name Behavior
...
@@ -44,3 +44,15 @@ Class name Behavior
========================= ===========================================================
========================= ===========================================================
When providing a custom ``Tag`` model it should be a ``ForeignKey`` to your tag model named ``"tag"``.
When providing a custom ``Tag`` model it should be a ``ForeignKey`` to your tag model named ``"tag"``.
.. class:: TagBase
.. method:: slugify(tag, i=None)
By default ``taggit`` uses :func:`django.template.defaultfilters.slugify`
to calculate a slug for a given tag. However, if you want to implement
your own logic you can override this method, which receives the ``tag``
(a string), and ``i``, which is either ``None`` or an integer, which
signifies how many times the slug for this tag has been attempted to be
calculated, it is ``None`` on the first time, and the counting begins
at ``1`` thereafter.
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