Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
docs(models): Update model names #66
Browse files Browse the repository at this point in the history
The model names in the docs have been updated to match the changes made
in tag_fields model names.

closes #66
  • Loading branch information
imAsparky committed May 9, 2023
1 parent 652c0be commit de364b4
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 28 deletions.
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ are permitted provided that the following conditions are met:
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of django-taggit nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
3. Neither the names of django-taggit or django-tag-fields nor the names of
its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Expand Down
6 changes: 3 additions & 3 deletions docs/source/admin.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Using tags in the admin
=======================

By default if you have a :class:`TaggableManager` on your model it will show up
By default if you have a :class:`ModelTagsManager` on your model it will show up
in the admin, just as it will in any other form.

If you are specifying :attr:`ModelAdmin.fieldsets
<django.contrib.admin.ModelAdmin.fieldsets>`, include the name of the
:class:`TaggableManager` as a field::
:class:`ModelTagsManager` as a field::

fieldsets = (
(None, {'fields': ('tags',)}),
Expand All @@ -16,7 +16,7 @@ Including tags in ``ModelAdmin.list_display``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

One important thing to note is that you *cannot* include a
:class:`TaggableManager` in :attr:`ModelAdmin.list_display
:class:`ModelTagsManager` in :attr:`ModelAdmin.list_display
<django.contrib.admin.ModelAdmin.list_display>`. If you do you'll see an
exception that looks like::

Expand Down
10 changes: 5 additions & 5 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
The API
=======

After you've got your ``TaggableManager`` added to your model you can start
After you've got your ``ModelTagsManager`` added to your model you can start
playing around with the API.

.. class:: TaggableManager([verbose_name="Tags", help_text="A comma-separated list of tags.", through=None, blank=False])
.. class:: ModelTagsManager([verbose_name="Tags", help_text="A comma-separated list of tags.", through=None, blank=False])

:param verbose_name: The verbose_name for this field.
:param help_text: The help_text to be used in forms (including the admin).
Expand Down Expand Up @@ -85,19 +85,19 @@ playing around with the API.
.. hint::

You can subclass ``_TaggableManager`` (note the underscore) to add
methods or functionality. ``TaggableManager`` takes an optional
methods or functionality. ``ModelTagsManager`` takes an optional
manager keyword argument for your custom class, like this::

class Food(models.Model):
# ... fields here
tags = TaggableManager(manager=_CustomTaggableManager)
tags = ModelTagsManager(manager=_CustomTaggableManager)

Filtering
~~~~~~~~~

To find all of a model with a specific tags you can filter, using the normal
Django ORM API. For example if you had a ``Food`` model, whose
``TaggableManager`` was named ``tags``, you could find all the delicious fruit
``ModelTagsManager`` was named ``tags``, you could find all the ``delicious`` fruit
like so::

>>> Food.objects.filter(tags__name__in=["delicious"])
Expand Down
3 changes: 3 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Changelog
=========

.. include:: ../../CHANGELOG.md
22 changes: 11 additions & 11 deletions docs/source/custom_tagging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ Your intermediary model must be a subclass of
``tag_fields.models.TaggedItemThroughBase`` with a foreign key to your content
model named ``content_object``.

Pass this intermediary model as the ``through`` argument to ``TaggableManager``:
Pass this intermediary model as the ``through`` argument to ``ModelTagsManager``:

.. code-block:: python
from django.db import models
from tag_fields.managers import TaggableManager
from tag_fields.managers import ModelTagsManager
from tag_fields.models import TaggedItemThroughBase
Expand All @@ -55,7 +55,7 @@ Pass this intermediary model as the ``through`` argument to ``TaggableManager``:
class Food(models.Model):
# ... fields here
tags = TaggableManager(through=TaggedFood)
tags = ModelTagsManager(through=TaggedFood)
Once this is done, the API works the same as for GFK-tagged models.
Expand All @@ -74,7 +74,7 @@ For example, if your primary key is a string:
from django.db import models
from tag_fields.managers import TaggableManager
from tag_fields.managers import ModelTagsManager
from tag_fields.models import (
GenericFKTaggedItemThroughBase,
TaggedItemThroughBase,
Expand All @@ -87,7 +87,7 @@ For example, if your primary key is a string:
food_id = models.CharField(primary_key=True)
# ... fields here
tags = TaggableManager(through=GenericStringTaggedItem)
tags = ModelTagsManager(through=GenericStringTaggedItem)
UUIDFKTaggedItemThroughBase
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -101,7 +101,7 @@ to use with models using a UUID primary key:
from django.db import models
from django.utils.translation import gettext_lazy as _
from tag_fields.managers import TaggableManager
from tag_fields.managers import ModelTagsManager
from tag_fields.models import (
UUIDFKTaggedItemThroughBase,
TaggedItemThroughBase,
Expand All @@ -120,15 +120,15 @@ to use with models using a UUID primary key:
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
# ... fields here
tags = TaggableManager(through=UUIDTaggedItem)
tags = ModelTagsManager(through=UUIDTaggedItem)
Custom tag
~~~~~~~~~~

When providing a custom ``Tag`` model, it should be a ``ForeignKey`` to your
tag model named ``"tag"``. If your custom ``Tag`` model has extra parameters
you want to initialize during setup, you can pass it along via the
``tag_kwargs`` parameter of ``TaggableManager.add``.
``tag_kwargs`` parameter of ``ModelTagsManager.add``.

For example, ``my_food.tags.add("tag_name1", "tag_name2", tag_kwargs={"my_field":3})``:

Expand All @@ -137,7 +137,7 @@ For example, ``my_food.tags.add("tag_name1", "tag_name2", tag_kwargs={"my_field"
from django.db import models
from django.utils.translation import gettext_lazy as _
from tag_fields.managers import TaggableManager
from tag_fields.managers import ModelTagsManager
from tag_fields.models import TagBase, GenericFKTaggedItemThroughBase
Expand Down Expand Up @@ -168,13 +168,13 @@ For example, ``my_food.tags.add("tag_name1", "tag_name2", tag_kwargs={"my_field"
class Food(models.Model):
# ... fields here
tags = TaggableManager(through=TaggedWhatever)
tags = ModelTagsManager(through=TaggedWhatever)
class Drink(models.Model):
# ... fields here
tags = TaggableManager(through=TaggedWhatever)
tags = ModelTagsManager(through=TaggedWhatever)
.. class:: TagBase
Expand Down
2 changes: 1 addition & 1 deletion docs/source/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Tags in forms
=============

The ``TaggableManager`` will show up automatically as a field in a
The ``ModelTagsManager`` will show up automatically as a field in a
``ModelForm`` or in the admin. Tags input via the form field are parsed
as follows:

Expand Down
4 changes: 2 additions & 2 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ And then, to any model you want tagged, do the following.
from django.db import models
from tag_fields.managers import TaggableManager
from tag_fields.managers import ModelTagsManager
class Food(models.Model):
# ... fields here
tags = TaggableManager()
tags = ModelTagsManager()
.. tip::
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to django-tag-fields's documentation!
=============================================
Welcome to django-tag-fields documentation!
===========================================

This project is a hard clone of `Jazzband django-taggit
<https://github.com/jazzband/django-taggit>`_.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/serializers.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Usage With Django Rest Framework
================================

To add tags into a ``TaggableManager()`` using ``django-tag-fields``, the usual
To add tags into a ``ModelTagsManager()`` using ``django-tag-fields``, the usual
``Serializer`` from Django REST Framework cannot be used.

Attempting to save the tags into a list using ``DRF Serializer`` will cause
Expand Down

0 comments on commit de364b4

Please sign in to comment.