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
c6eb0581
authored
Aug 20, 2010
by
Alex Gaynor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up the formatting of the docs
parent
7091e95a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
30 deletions
+26
-30
docs/api.txt
+26
-30
No files found.
docs/api.txt
View file @
c6eb0581
...
...
@@ -4,53 +4,49 @@ The API
After you've got your ``TaggableManager`` added to your model you can start
playing around with the API.
.. class:: TaggableManager
add(*tags)
~~~~~~~~~~
.. method:: add(*tags)
This adds tags to an object. The tags can be either ``Tag`` instances, or
strings::
This adds tags to an object. The tags can be either ``Tag`` instances, or
strings::
>>> apple.tags.all()
[]
>>> apple.tags.add("red", "green", "fruit")
.. method:: remove(*tags)
remove(*tags)
~~~~~~~~~~~~~
Removes a tag from an object. No exception is raised if the object
doesn't have that tag.
Removes a tag from an object. No exception is raised if the object doesn't have
that tag.
.. method:: clear()
clear()
~~~~~~~
Removes all tags from an object.
Removes all tags from an object.
.. method:: set(*tags)
set(*tags)
~~~~~~~~~~
Removes all the current tags and then adds the specified tags to the
object.
Removes all the current tags and then adds the specified tags to the object.
.. method: most_common()
most_common()
~~~~~~~~~~~~~
Returns a ``QuerySet`` of all tags, annotated with the number of times
they appear, available as the ``num_times`` attribute on each tag. The
``QuerySet``is ordered by ``num_times``, descending. The ``QuerySet``
is lazily evaluated, and can be sliced efficiently.
Returns a ``QuerySet`` of all tags, annotated with the number of times they
appear, available as the ``num_times`` attribute on each tag. The ``QuerySet``
is ordered by ``num_times``, descending. The ``QuerySet`` is lazily evaluated,
and can be sliced efficiently.
.. method:: similar_objects()
similar_objects()
~~~~~~~~~~~~~~~~~
Returns a list (not a lazy ``QuerySet``) of other objects tagged
similarly to this one, ordered with most similar first. Each object in
the list is decorated with a ``similar_tags`` attribute, the number of
tags it shares with this object.
Returns a list (not a lazy ``QuerySet``) of other objects tagged similarly to
this one, ordered with most similar first. Each object in the list is decorated
with a ``similar_tags`` attribute, the number of tags it shares with this
object.
If using generic tagging (the default), this method searches all tagged
objects. If querying on a model with its own tagging through table, only other
instances of the same model will be returned.
If the model is using generic tagging (the default), this method
searches tagged objects from all classes. If you are querying on a
model with its own tagging through table, only other instances of the
same model will be returned.
Filtering
~~~~~~~~~
...
...
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