Remove workaround for older unsupported Djangos

django.utils.encoding.force_text is available on all supported Djangos.
Can remove workaround to simplify the imports.
This commit is contained in:
Jon Dufresne 2018-11-04 17:06:31 -08:00
parent ec568b5ad9
commit 5180a422a5
5 changed files with 5 additions and 24 deletions

View File

@ -22,6 +22,7 @@ except ImportError: # Django<2.0
from django.conf import settings
from django.template.defaultfilters import pluralize
from django.utils.decorators import method_decorator
from django.utils.encoding import force_text
from django.views.decorators.http import require_POST
from .forms import (
@ -38,10 +39,6 @@ from .results import RowResult
from .tmp_storages import TempFolderStorage
from .signals import post_export, post_import
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
SKIP_ADMIN_LOG = getattr(settings, 'IMPORT_EXPORT_SKIP_ADMIN_LOG', False)
TMP_STORAGE_CLASS = getattr(settings, 'IMPORT_EXPORT_TMP_STORAGE_CLASS',

View File

@ -19,6 +19,7 @@ from django.db.models.query import QuerySet
from django.db.transaction import TransactionManagementError
from django.utils import six
from django.utils.safestring import mark_safe
from django.utils.encoding import force_text
from . import widgets
from .fields import Field
@ -34,10 +35,6 @@ except ImportError:
from django.db.models.fields.related import ForeignObjectRel
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
logger = logging.getLogger(__name__)
# Set default logging handler to avoid "No handler found" warnings.

View File

@ -4,18 +4,13 @@ from __future__ import unicode_literals
from decimal import Decimal
from datetime import datetime, date
from django.utils import datetime_safe, timezone, six
from django.utils.encoding import smart_text
from django.utils.encoding import smart_text, force_text
from django.utils.dateparse import parse_duration
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
import json
import ast
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
class Widget(object):
"""

View File

@ -4,11 +4,7 @@ from __future__ import unicode_literals
import os
from django.test import TestCase
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
from django.utils.encoding import force_text
from import_export.formats import base_formats

View File

@ -14,6 +14,7 @@ from django.db.models import Count
from django.db.models.fields import FieldDoesNotExist
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
from django.utils.html import strip_tags
from django.utils.encoding import force_text
from import_export import fields, resources, results, widgets
from import_export.instance_loaders import ModelInstanceLoader
@ -29,11 +30,6 @@ try:
except ImportError:
from django.utils.datastructures import SortedDict as OrderedDict
try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text
class MyResource(resources.Resource):
name = fields.Field()