diff --git a/autocomplete_light/autocomplete/base.py b/autocomplete_light/autocomplete/base.py index 219b47426..66af30db9 100644 --- a/autocomplete_light/autocomplete/base.py +++ b/autocomplete_light/autocomplete/base.py @@ -3,9 +3,9 @@ import six from django.urls import reverse, NoReverseMatch from django.core.exceptions import ImproperlyConfigured -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.html import escape -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ __all__ = ('AutocompleteInterface', 'AutocompleteBase') @@ -201,11 +201,11 @@ def choice_value(self, choice): Return the value of a choice. This simple implementation returns the textual representation. """ - return force_text(choice) + return force_str(choice) def choice_label(self, choice): """ Return the human-readable representation of a choice. This simple implementation returns the textual representation. """ - return force_text(choice) + return force_str(choice) diff --git a/autocomplete_light/autocomplete/choice_list.py b/autocomplete_light/autocomplete/choice_list.py index 85b79d412..be0cb79b0 100644 --- a/autocomplete_light/autocomplete/choice_list.py +++ b/autocomplete_light/autocomplete/choice_list.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from django.utils.encoding import force_text +from django.utils.encoding import force_str from .list import AutocompleteList @@ -33,7 +33,7 @@ class AutocompleteChoiceList(AutocompleteList): this against :py:attr:`choices` as an argument :py:func:`sorted`. """ def order_by(cls, choice): - return force_text(choice[1]).lower() + return force_str(choice[1]).lower() def choices_for_values(self): """ @@ -56,7 +56,7 @@ def choices_for_request(self): q = self.request.GET.get('q', '').lower().strip() for choice in self.choices: - m = force_text(choice[0]).lower() + force_text(choice[1]).lower() + m = force_str(choice[0]).lower() + force_str(choice[1]).lower() if q in m: requests_choices.append(choice) diff --git a/autocomplete_light/autocomplete/list.py b/autocomplete_light/autocomplete/list.py index 1e9c48b7a..5845f4b92 100644 --- a/autocomplete_light/autocomplete/list.py +++ b/autocomplete_light/autocomplete/list.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from django.utils.encoding import force_text +from django.utils.encoding import force_str __all__ = ('AutocompleteList',) @@ -31,7 +31,7 @@ class AutocompleteList(object): limit_choices = 20 def order_by(cls, choice): - return force_text(choice).lower() + return force_str(choice).lower() def choices_for_values(self): """ @@ -56,7 +56,7 @@ def choices_for_request(self): q = self.request.GET.get('q', '').lower().strip() for choice in self.choices: - if q in force_text(choice).lower(): + if q in force_str(choice).lower(): requests_choices.append(choice) return self.order_choices(requests_choices)[0:self.limit_choices] diff --git a/autocomplete_light/autocomplete/model.py b/autocomplete_light/autocomplete/model.py index 9e7d9faed..cece4285b 100644 --- a/autocomplete_light/autocomplete/model.py +++ b/autocomplete_light/autocomplete/model.py @@ -2,7 +2,7 @@ import six from django.db.models import Q -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.db import connection from ..settings import DEFAULT_SEARCH_FIELDS @@ -61,7 +61,7 @@ def choice_label(self, choice): """ Return the textual representation of the choice by default. """ - return force_text(choice) + return force_str(choice) def order_choices(self, choices): """ diff --git a/autocomplete_light/autocomplete/rest_model.py b/autocomplete_light/autocomplete/rest_model.py index a84e22845..50a131821 100644 --- a/autocomplete_light/autocomplete/rest_model.py +++ b/autocomplete_light/autocomplete/rest_model.py @@ -2,7 +2,7 @@ import six from django import http -from django.utils.encoding import force_text +from django.utils.encoding import force_str from .model import AutocompleteModel @@ -67,7 +67,7 @@ def model_for_source_url(self, url): def choices_for_request(self): choices = super(AutocompleteRestModel, self).choices_for_request() - unicodes = [force_text(choice) for choice in choices] + unicodes = [force_str(choice) for choice in choices] slots = self.limit_choices - len(choices) @@ -76,7 +76,7 @@ def choices_for_request(self): for choice in self.get_remote_choices(slots): # avoid data that's already in local - if force_text(choice) in unicodes: + if force_str(choice) in unicodes: continue choices.append(choice) diff --git a/autocomplete_light/compat.py b/autocomplete_light/compat.py index f7ef42a04..e32f89db1 100644 --- a/autocomplete_light/compat.py +++ b/autocomplete_light/compat.py @@ -1,11 +1,11 @@ from django import VERSION if VERSION < (1, 5): - from django.conf.urls.defaults import patterns, url # noqa + from django.urls.defaults import patterns, url # noqa elif VERSION < (1, 8): - from django.conf.urls import patterns, url # noqa + from django.urls import patterns, url # noqa else: - from django.conf.urls import url # noqa + from django.urls import re_path as url # noqa patterns = None @@ -20,7 +20,7 @@ from django.utils.module_loading import import_string except ImportError: from importlib import import_module - from django.utils import six + import six import sys def import_string(dotted_path): diff --git a/autocomplete_light/example_apps/security_test/templates/security_test/item_form.html b/autocomplete_light/example_apps/security_test/templates/security_test/item_form.html index f5e7d9749..f7d1e1144 100644 --- a/autocomplete_light/example_apps/security_test/templates/security_test/item_form.html +++ b/autocomplete_light/example_apps/security_test/templates/security_test/item_form.html @@ -1,4 +1,4 @@ -{% load staticfiles %} +{% load static %} {% include 'autocomplete_light/static.html' %} diff --git a/autocomplete_light/example_apps/unuseable_virtualfield/vote_models.py b/autocomplete_light/example_apps/unuseable_virtualfield/vote_models.py index 6629814c2..72dd64fc2 100644 --- a/autocomplete_light/example_apps/unuseable_virtualfield/vote_models.py +++ b/autocomplete_light/example_apps/unuseable_virtualfield/vote_models.py @@ -9,7 +9,7 @@ from django.db import IntegrityError, models, transaction from django.db.models import Count from django.db.models.query import QuerySet -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ # Django 1.5 add support for custom auth user model if django.VERSION >= (1, 5): diff --git a/autocomplete_light/forms.py b/autocomplete_light/forms.py index 26cd96f6e..904ac828a 100644 --- a/autocomplete_light/forms.py +++ b/autocomplete_light/forms.py @@ -20,8 +20,8 @@ from django.db.models import ForeignKey, ManyToManyField, OneToOneField from django.forms.models import modelform_factory as django_modelform_factory from django.forms.models import ModelFormMetaclass as DjangoModelFormMetaclass -from django.utils.encoding import force_text -from django.utils.translation import ugettext_lazy as _ +from django.utils.encoding import force_str +from django.utils.translation import gettext_lazy as _ from .contrib.taggit_field import TaggitField from .fields import (GenericModelChoiceField, GenericModelMultipleChoiceField, @@ -52,7 +52,7 @@ class SelectMultipleHelpTextRemovalMixin(forms.BaseModelForm): def __init__(self, *args, **kwargs): super(SelectMultipleHelpTextRemovalMixin, self).__init__(*args, **kwargs) - msg = force_text(M) + msg = force_str(M) for name, field in self.fields.items(): widget = field.widget diff --git a/autocomplete_light/templates/autocomplete_light/static.html b/autocomplete_light/templates/autocomplete_light/static.html index a26331bc4..c91012706 100644 --- a/autocomplete_light/templates/autocomplete_light/static.html +++ b/autocomplete_light/templates/autocomplete_light/static.html @@ -1,5 +1,4 @@ -{% load static from staticfiles %} - +{% load static %} {% include 'autocomplete_light/_ajax_csrf.html' %} diff --git a/autocomplete_light/templates/autocomplete_light/widget.html b/autocomplete_light/templates/autocomplete_light/widget.html index 3293e6fe9..45a3915b1 100644 --- a/autocomplete_light/templates/autocomplete_light/widget.html +++ b/autocomplete_light/templates/autocomplete_light/widget.html @@ -1,5 +1,5 @@ {% load i18n l10n %} -{% load staticfiles %} +{% load static %} {% load autocomplete_light_tags %} {% block widget_open %} diff --git a/autocomplete_light/tests/autocomplete/test_model.py b/autocomplete_light/tests/autocomplete/test_model.py index 01588a56e..3d4bb812f 100644 --- a/autocomplete_light/tests/autocomplete/test_model.py +++ b/autocomplete_light/tests/autocomplete/test_model.py @@ -4,7 +4,7 @@ import pytest from django import VERSION -from django.utils.encoding import force_text +from django.utils.encoding import force_str from autocomplete_light.example_apps.autocomplete_test_case_app.models import ( NonIntegerPk, SubGroup, CustomSchema, CustomIntegerPk, Caps) @@ -125,18 +125,18 @@ def get_autocomplete_html_tests(self): 'fixture': make_get_request('q=j'), 'expected': ''.join([ '%s' % ( - self.jack.pk, force_text(self.jack)), + self.jack.pk, force_str(self.jack)), '%s' % ( - self.james.pk, force_text(self.james)), + self.james.pk, force_str(self.james)), ]) }, { 'fixture': make_get_request(), 'expected': ''.join([ '%s' % ( - self.abe.pk, force_text(self.abe)), + self.abe.pk, force_str(self.abe)), '%s' % ( - self.jack.pk, force_text(self.jack)), + self.jack.pk, force_str(self.jack)), ]) }, ) diff --git a/autocomplete_light/tests/autocomplete/test_template.py b/autocomplete_light/tests/autocomplete/test_template.py index b14012270..f5292fe14 100644 --- a/autocomplete_light/tests/autocomplete/test_template.py +++ b/autocomplete_light/tests/autocomplete/test_template.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals from django.template import Context, Template -from django.utils.encoding import force_text +from django.utils.encoding import force_str from ...example_apps.autocomplete_test_case_app.models import Group, User from .case import * @@ -61,9 +61,9 @@ def get_autocomplete_html_tests(self): 'expected': ''.join([ '