Skip to content

Commit

Permalink
Merge pull request #740 from jazzband/release-cleanup
Browse files Browse the repository at this point in the history
Release Cleanup + Preparing for Release 1.5.0
  • Loading branch information
rtpg committed Jun 30, 2021
2 parents bd342ab + 3116ca2 commit 19b8222
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
django-taggit was originally created by Alex Gaynor.

django-taggit-serializer was originally created by Paul Oostenrijk.

The following is a list of much appreciated contributors:

Nathan Borror <nathan@playgroundblues.com>
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ Changelog

* (nothing here yet)


1.5.0 (2021-05-30)
~~~~~~~~~~~~~~~~~~

* Vendor in the `django-taggit-serializer` project (under `taggit.serializers`).
* Add Arabic translation.
* Add Ukranian translation.


1.4.0 (2021-04-19)
~~~~~~~~~~~~~~~~~~

Expand Down
4 changes: 0 additions & 4 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@ Frequently Asked Questions
- How can I use this with factory_boy?

Since these are all built off of many-to-many relationships, you can check out `factory_boy's documentation on this topic <https://factoryboy.readthedocs.io/en/stable/recipes.html#simple-many-to-many-relationship>`_ and get some ideas on how to deal with tags.

- How can I use this with Django Rest Framework?

`django-taggit-serializer <https://github.com/glemmaPaul/django-taggit-serializer>`_ offers support for working with tags and DRF together.
16 changes: 9 additions & 7 deletions taggit/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
import json

# Third party
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy
from rest_framework import serializers


class TagList(list):
def __init__(self, *args, **kwargs):
pretty_print = kwargs.pop("pretty_print", True)
list.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
self.pretty_print = pretty_print

def __add__(self, rhs):
return TagList(list.__add__(self, rhs))
return TagList(super().__add__(rhs))

def __getitem__(self, item):
result = list.__getitem__(self, item)
result = super().__getitem__(item)
try:
return TagList(result)
except TypeError:
Expand All @@ -36,12 +36,14 @@ def __str__(self):
class TagListSerializerField(serializers.Field):
child = serializers.CharField()
default_error_messages = {
"not_a_list": _('Expected a list of items but got type "{input_type}".'),
"invalid_json": _(
"not_a_list": gettext_lazy(
'Expected a list of items but got type "{input_type}".'
),
"invalid_json": gettext_lazy(
"Invalid json list. A tag list submitted in string"
" form must be valid json."
),
"not_a_str": _("All list items must be of string type."),
"not_a_str": gettext_lazy("All list items must be of string type."),
}
order_by = None

Expand Down

0 comments on commit 19b8222

Please sign in to comment.