diff --git a/shop/forms/base.py b/shop/forms/base.py index fb3294e4e..87948d296 100644 --- a/shop/forms/base.py +++ b/shop/forms/base.py @@ -3,7 +3,7 @@ from django.contrib.auth import get_user_model from django.core.exceptions import ValidationError from django.forms import widgets -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.functional import cached_property from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ @@ -57,13 +57,13 @@ def as_text(self): line.append(dict(bound_field.field.choices)[cast_to(v)]) except (AttributeError, KeyError): pass - output.append(force_text(', '.join(line))) + output.append(force_str(', '.join(line))) elif value: try: value = dict(bound_field.field.choices)[value] except (AttributeError, KeyError): pass - output.append(force_text(value)) + output.append(force_str(value)) return mark_safe('\n'.join(output)) def get_response_data(self): diff --git a/shop/models/fields.py b/shop/models/fields.py index fc441aae5..328564889 100644 --- a/shop/models/fields.py +++ b/shop/models/fields.py @@ -1,7 +1,7 @@ import enum from django.conf import settings from django.db import models -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ @@ -87,7 +87,7 @@ class Color(ChoiceEnum): ) """ def __str__(self): - return force_text(self.label) + return force_str(self.label) class ChoiceEnumField(models.PositiveSmallIntegerField): diff --git a/shop/models/product.py b/shop/models/product.py index 7b16899b4..e35b5246b 100644 --- a/shop/models/product.py +++ b/shop/models/product.py @@ -9,7 +9,7 @@ from django.db.models.aggregates import Sum from django.db.models.functions import Coalesce from django.utils import timezone -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ try: @@ -228,7 +228,7 @@ def product_type(self): """ Returns the polymorphic type of the product. """ - return force_text(self.polymorphic_ctype) + return force_str(self.polymorphic_ctype) product_type.short_description = _("Product type") @property diff --git a/shop/templatetags/shop_tags.py b/shop/templatetags/shop_tags.py index 6d5bf1333..f86ffb95b 100644 --- a/shop/templatetags/shop_tags.py +++ b/shop/templatetags/shop_tags.py @@ -4,7 +4,7 @@ from django.template import Node, TemplateSyntaxError from django.template.loader import select_template from django.utils import formats -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.safestring import mark_safe from django.utils.dateformat import format, time_format from django.utils.timezone import datetime @@ -37,7 +37,7 @@ def render(self, context): except CartModel.DoesNotExist: cart_data = {'total_quantity': 0, 'num_items': 0} context.update({ - 'cart_as_json': mark_safe(force_text(cart_data)), + 'cart_as_json': mark_safe(force_str(cart_data)), 'has_dropdown': self.with_items != CartItems.without, }) return self.get_template().render(context) @@ -123,4 +123,4 @@ def rest_json(value, arg=None): else: msg = "Given value must be of type dict, OrderedDict, list or tuple but it is {}." raise ValueError(msg.format(value.__class__.__name__)) - return mark_safe(force_text(data)) + return mark_safe(force_str(data)) diff --git a/tests/testshop/modifiers.py b/tests/testshop/modifiers.py index 2ab6e8bdc..38304581b 100644 --- a/tests/testshop/modifiers.py +++ b/tests/testshop/modifiers.py @@ -1,9 +1,8 @@ from shop.payment.modifiers import PayInAdvanceModifier -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class ComplexPayInAdvanceModifier(PayInAdvanceModifier): identifier = "complex-pay-in-advance-modifier" def get_choice(self): return (self.identifier, _("Pay in advance with complex payment system X")) -