Skip to content

Commit d9ea2b3

Browse files
committed
Merge branch 'release/v0.3.4'
2 parents ee10fdc + 1ed2ea0 commit d9ea2b3

File tree

5 files changed

+37
-13
lines changed

5 files changed

+37
-13
lines changed

CHANGELOG.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
Django Tagging Changelog
33
========================
44

5+
Version 0.3.4, 7th November 2014:
6+
---------------------------------
7+
8+
* Fix unicode errors in admin
9+
510
Version 0.3.3, 15th October 2014:
6-
----------------------------------
11+
---------------------------------
712

813
* Added support for Django 1.7
914

tagging/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (0, 3, 3, "final", 0)
1+
VERSION = (0, 3, 4, "final", 0)
22

33

44
def get_version():

tagging/models.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
"""
22
Models and managers for generic tagging.
33
"""
4+
from django.db import models
5+
from django.db import connection
6+
from django.utils.encoding import smart_text
7+
from django.utils.encoding import python_2_unicode_compatible
48
from django.contrib.contenttypes import generic
59
from django.contrib.contenttypes.models import ContentType
6-
from django.db import connection, models
7-
from django.utils.encoding import python_2_unicode_compatible
810
from django.utils.translation import ugettext_lazy as _
911

1012
from . import settings
11-
from .utils import (calculate_cloud, get_tag_list, get_queryset_and_model,
12-
parse_tag_input, LOGARITHMIC)
13+
from .utils import LOGARITHMIC
14+
from .utils import get_tag_list
15+
from .utils import calculate_cloud
16+
from .utils import parse_tag_input
17+
from .utils import get_queryset_and_model
1318

1419

1520
qn = connection.ops.quote_name
@@ -490,4 +495,4 @@ class Meta:
490495
verbose_name_plural = _('tagged items')
491496

492497
def __str__(self):
493-
return '%s [%s]' % (self.object, self.tag)
498+
return '%s [%s]' % (smart_text(self.object), smart_text(self.tag))

tagging/tests/models.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from tagging.fields import TagField
55

66

7-
@python_2_unicode_compatible
87
class Perch(models.Model):
98
size = models.IntegerField()
109
smelly = models.BooleanField(default=True)
@@ -44,11 +43,9 @@ class Meta:
4443
ordering = ['name']
4544

4645

47-
@python_2_unicode_compatible
4846
class FormTest(models.Model):
4947
tags = TagField('Test', help_text='Test')
5048

5149

52-
@python_2_unicode_compatible
5350
class FormTestNull(models.Model):
5451
tags = TagField(null=True)

tagging/tests/tests.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@
44
import os
55

66
from django import forms
7+
from django.utils import six
78
from django.db.models import Q
89
from django.test import TestCase
910

1011
from tagging import settings
1112
from tagging.forms import TagField
1213
from tagging.models import Tag, TaggedItem
13-
from tagging.tests.models import Article, Link, Perch, Parrot, FormTest
14-
from tagging.utils import calculate_cloud, edit_string_for_tags, get_tag_list, get_tag, parse_tag_input
14+
from tagging.tests.models import Article
15+
from tagging.tests.models import Link
16+
from tagging.tests.models import Perch
17+
from tagging.tests.models import Parrot
18+
from tagging.tests.models import FormTest
19+
from tagging.tests.models import FormTestNull
1520
from tagging.utils import LINEAR
16-
21+
from tagging.utils import get_tag
22+
from tagging.utils import get_tag_list
23+
from tagging.utils import calculate_cloud
24+
from tagging.utils import parse_tag_input
25+
from tagging.utils import edit_string_for_tags
1726

1827
#############
1928
# Utilities #
@@ -326,6 +335,14 @@ def test_update_tags_exotic_characters(self):
326335
self.assertEqual(len(tags), 1)
327336
self.assertEqual(tags[0].name, '你好')
328337

338+
def test_unicode_tagged_object(self):
339+
self.dead_parrot.state = u"dëad"
340+
self.dead_parrot.save()
341+
Tag.objects.update_tags(self.dead_parrot, u'föo')
342+
items = TaggedItem.objects.all()
343+
self.assertEqual(len(items), 1)
344+
self.assertEqual(six.text_type(items[0]), u"dëad [föo]")
345+
329346
def test_update_tags_with_none(self):
330347
# start off in a known, mildly interesting state
331348
Tag.objects.update_tags(self.dead_parrot, 'foo bar baz')

0 commit comments

Comments
 (0)