diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-12 12:32:08 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-12 14:44:40 +0200 |
| commit | d4a0b27838c815af87698920cc4db7d2afd6f05b (patch) | |
| tree | 6fedc7203389ab1f80f8cc7e913230c51e9b8776 /django/forms/forms.py | |
| parent | 79d62a71751140315227891bbe175630f9d3edc3 (diff) | |
[py3] Refactored __unicode__ to __str__.
* Renamed the __unicode__ methods
* Applied the python_2_unicode_compatible decorator
* Removed the StrAndUnicode mix-in that is superseded by
python_2_unicode_compatible
* Kept the __unicode__ methods in classes that specifically
test it under Python 2
Diffstat (limited to 'django/forms/forms.py')
| -rw-r--r-- | django/forms/forms.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py index 45b758202a..3299c2becc 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -12,7 +12,7 @@ from django.forms.util import flatatt, ErrorDict, ErrorList from django.forms.widgets import Media, media_property, TextInput, Textarea from django.utils.datastructures import SortedDict from django.utils.html import conditional_escape, format_html -from django.utils.encoding import StrAndUnicode, smart_text, force_text +from django.utils.encoding import smart_text, force_text, python_2_unicode_compatible from django.utils.safestring import mark_safe from django.utils import six @@ -68,7 +68,8 @@ class DeclarativeFieldsMetaclass(type): new_class.media = media_property(new_class) return new_class -class BaseForm(StrAndUnicode): +@python_2_unicode_compatible +class BaseForm(object): # This is the main implementation of all the Form logic. Note that this # class is different than Form. See the comments by the Form class for more # information. Any improvements to the form API should be made to *this* @@ -95,7 +96,7 @@ class BaseForm(StrAndUnicode): # self.base_fields. self.fields = copy.deepcopy(self.base_fields) - def __unicode__(self): + def __str__(self): return self.as_table() def __iter__(self): @@ -387,7 +388,8 @@ class Form(six.with_metaclass(DeclarativeFieldsMetaclass, BaseForm)): # to define a form using declarative syntax. # BaseForm itself has no way of designating self.fields. -class BoundField(StrAndUnicode): +@python_2_unicode_compatible +class BoundField(object): "A Field plus data" def __init__(self, form, field, name): self.form = form @@ -402,7 +404,7 @@ class BoundField(StrAndUnicode): self.label = self.field.label self.help_text = field.help_text or '' - def __unicode__(self): + def __str__(self): """Renders this field as an HTML widget.""" if self.field.show_hidden_initial: return self.as_widget() + self.as_hidden(only_initial=True) |
