Skip to content

Commit 879f258

Browse files
committed
Make the code working with Django 2+
1 parent fabd5cf commit 879f258

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

tagging/models.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from django.db import models
55
from django.db import connection
66
from django.utils.encoding import smart_text
7-
from django.utils.encoding import python_2_unicode_compatible
87
from django.utils.translation import ugettext_lazy as _
98
from django.contrib.contenttypes.models import ContentType
109
from django.contrib.contenttypes.fields import GenericForeignKey
@@ -474,7 +473,6 @@ def get_related(self, obj, queryset_or_model, num=None):
474473
# Models #
475474
##########
476475

477-
@python_2_unicode_compatible
478476
class Tag(models.Model):
479477
"""
480478
A tag.
@@ -494,7 +492,6 @@ def __str__(self):
494492
return self.name
495493

496494

497-
@python_2_unicode_compatible
498495
class TaggedItem(models.Model):
499496
"""
500497
Holds the relationship between a tag and the item being tagged.

tagging/utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55
import math
66

7-
from django.utils import six
87
from django.db.models.query import QuerySet
98
from django.utils.encoding import force_text
109
from django.utils.translation import ugettext as _
@@ -171,18 +170,18 @@ def get_tag_list(tags):
171170
return [tags]
172171
elif isinstance(tags, QuerySet) and tags.model is Tag:
173172
return tags
174-
elif isinstance(tags, six.string_types):
173+
elif isinstance(tags, str):
175174
return Tag.objects.filter(name__in=parse_tag_input(tags))
176175
elif isinstance(tags, (list, tuple)):
177176
if len(tags) == 0:
178177
return tags
179178
contents = set()
180179
for item in tags:
181-
if isinstance(item, six.string_types):
180+
if isinstance(item, str):
182181
contents.add('string')
183182
elif isinstance(item, Tag):
184183
contents.add('tag')
185-
elif isinstance(item, six.integer_types):
184+
elif isinstance(item, int):
186185
contents.add('int')
187186
if len(contents) == 1:
188187
if 'string' in contents:
@@ -216,9 +215,9 @@ def get_tag(tag):
216215
return tag
217216

218217
try:
219-
if isinstance(tag, six.string_types):
218+
if isinstance(tag, str):
220219
return Tag.objects.get(name=tag)
221-
elif isinstance(tag, six.integer_types):
220+
elif isinstance(tag, int):
222221
return Tag.objects.get(id=tag)
223222
except Tag.DoesNotExist:
224223
pass

0 commit comments

Comments
 (0)