mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
[py3] Replaced basestring by six.string_types.
This commit is contained in:
@@ -11,6 +11,7 @@ from django.utils import datetime_safe
|
||||
from django.utils.dates import MONTHS
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.formats import get_format
|
||||
from django.utils import six
|
||||
from django.conf import settings
|
||||
|
||||
__all__ = ('SelectDateWidget',)
|
||||
@@ -64,7 +65,7 @@ class SelectDateWidget(Widget):
|
||||
year_val, month_val, day_val = value.year, value.month, value.day
|
||||
except AttributeError:
|
||||
year_val = month_val = day_val = None
|
||||
if isinstance(value, basestring):
|
||||
if isinstance(value, six.string_types):
|
||||
if settings.USE_L10N:
|
||||
try:
|
||||
input_format = get_format('DATE_INPUT_FORMATS')[0]
|
||||
|
||||
@@ -22,6 +22,7 @@ from django.forms.widgets import (TextInput, PasswordInput, HiddenInput,
|
||||
from django.utils import formats
|
||||
from django.utils.encoding import smart_unicode, force_unicode
|
||||
from django.utils.ipv6 import clean_ipv6_address
|
||||
from django.utils import six
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
# Provide this import for backwards compatibility.
|
||||
@@ -445,7 +446,7 @@ class RegexField(CharField):
|
||||
return self._regex
|
||||
|
||||
def _set_regex(self, regex):
|
||||
if isinstance(regex, basestring):
|
||||
if isinstance(regex, six.string_types):
|
||||
regex = re.compile(regex, re.UNICODE)
|
||||
self._regex = regex
|
||||
if hasattr(self, '_regex_validator') and self._regex_validator in self.validators:
|
||||
@@ -633,7 +634,7 @@ class BooleanField(Field):
|
||||
# will submit for False. Also check for '0', since this is what
|
||||
# RadioSelect will provide. Because bool("True") == bool('1') == True,
|
||||
# we don't need to handle that explicitly.
|
||||
if isinstance(value, basestring) and value.lower() in ('false', '0'):
|
||||
if isinstance(value, six.string_types) and value.lower() in ('false', '0'):
|
||||
value = False
|
||||
else:
|
||||
value = bool(value)
|
||||
|
||||
@@ -16,6 +16,7 @@ from django.utils.html import conditional_escape, format_html, format_html_join
|
||||
from django.utils.translation import ugettext, ugettext_lazy
|
||||
from django.utils.encoding import StrAndUnicode, force_unicode
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils import six
|
||||
from django.utils import datetime_safe, formats
|
||||
from django.utils import six
|
||||
|
||||
@@ -522,7 +523,7 @@ class CheckboxInput(Widget):
|
||||
value = data.get(name)
|
||||
# Translate true and false strings to boolean values.
|
||||
values = {'true': True, 'false': False}
|
||||
if isinstance(value, basestring):
|
||||
if isinstance(value, six.string_types):
|
||||
value = values.get(value.lower(), value)
|
||||
return value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user