diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-07-20 14:48:51 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-07-22 09:29:54 +0200 |
| commit | bdca5ea345c548a82a80d198906818c9ccbef896 (patch) | |
| tree | 5c3f5fe5ad2522175d67b96a1fce1ff1763ba125 /django/forms | |
| parent | 3cb2457f46b3e40ff6b6acffcb3fd44cbea091e5 (diff) | |
[py3] Replaced unicode/str by six.text_type/bytes.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/fields.py | 4 | ||||
| -rw-r--r-- | django/forms/forms.py | 4 | ||||
| -rw-r--r-- | django/forms/formsets.py | 7 | ||||
| -rw-r--r-- | django/forms/models.py | 4 |
4 files changed, 10 insertions, 9 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index 4c4209dddd..9c944ad0ac 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -331,10 +331,10 @@ class BaseTemporalField(Field): def to_python(self, value): # Try to coerce the value to unicode. unicode_value = force_unicode(value, strings_only=True) - if isinstance(unicode_value, unicode): + if isinstance(unicode_value, six.text_type): value = unicode_value.strip() # If unicode, try to strptime against each input format. - if isinstance(value, unicode): + if isinstance(value, six.text_type): for format in self.input_formats: try: return self.strptime(value, format) diff --git a/django/forms/forms.py b/django/forms/forms.py index 0af71918d8..4bc3ee9d26 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -151,7 +151,7 @@ class BaseForm(StrAndUnicode): if bf.is_hidden: if bf_errors: top_errors.extend(['(Hidden field %s) %s' % (name, force_unicode(e)) for e in bf_errors]) - hidden_fields.append(unicode(bf)) + hidden_fields.append(six.text_type(bf)) else: # Create a 'class="..."' atribute if the row should have any # CSS classes applied. @@ -181,7 +181,7 @@ class BaseForm(StrAndUnicode): output.append(normal_row % { 'errors': force_unicode(bf_errors), 'label': force_unicode(label), - 'field': unicode(bf), + 'field': six.text_type(bf), 'help_text': help_text, 'html_class_attr': html_class_attr }) diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 31ca088bdb..8a61f6cd62 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -7,6 +7,7 @@ from django.forms.util import ErrorList from django.forms.widgets import Media, HiddenInput from django.utils.encoding import StrAndUnicode from django.utils.safestring import mark_safe +from django.utils import six from django.utils.translation import ugettext as _ @@ -345,17 +346,17 @@ class BaseFormSet(StrAndUnicode): # probably should be. It might make sense to render each form as a # table row with each field as a td. forms = ' '.join([form.as_table() for form in self]) - return mark_safe('\n'.join([unicode(self.management_form), forms])) + return mark_safe('\n'.join([six.text_type(self.management_form), forms])) def as_p(self): "Returns this formset rendered as HTML <p>s." forms = ' '.join([form.as_p() for form in self]) - return mark_safe('\n'.join([unicode(self.management_form), forms])) + return mark_safe('\n'.join([six.text_type(self.management_form), forms])) def as_ul(self): "Returns this formset rendered as HTML <li>s." forms = ' '.join([form.as_ul() for form in self]) - return mark_safe('\n'.join([unicode(self.management_form), forms])) + return mark_safe('\n'.join([six.text_type(self.management_form), forms])) def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, can_delete=False, max_num=None): diff --git a/django/forms/models.py b/django/forms/models.py index 1ef308d93a..0831d5f4b2 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -576,7 +576,7 @@ class BaseModelFormSet(BaseFormSet): else: return ugettext("Please correct the duplicate data for %(field)s, " "which must be unique.") % { - "field": get_text_list(unique_check, unicode(_("and"))), + "field": get_text_list(unique_check, six.text_type(_("and"))), } def get_date_error_message(self, date_check): @@ -584,7 +584,7 @@ class BaseModelFormSet(BaseFormSet): "which must be unique for the %(lookup)s in %(date_field)s.") % { 'field_name': date_check[2], 'date_field': date_check[3], - 'lookup': unicode(date_check[1]), + 'lookup': six.text_type(date_check[1]), } def get_form_error(self): |
