diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-05-17 16:33:36 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-05-17 18:08:58 +0200 |
| commit | 9c487b5974ee7e7f196079611d7352364e8873ed (patch) | |
| tree | efc6ffa38da07b4302e145c33047cf2c41da105a /django/forms | |
| parent | b1bfd9630ef049070b0cd6ae215470d3d1facd40 (diff) | |
Replaced an antiquated pattern.
Thanks Lennart Regebro for pointing it out.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/forms.py | 2 | ||||
| -rw-r--r-- | django/forms/formsets.py | 2 | ||||
| -rw-r--r-- | django/forms/widgets.py | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py index f3a0fe6b38..b231de421a 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -523,7 +523,7 @@ class BoundField(object): widget = self.field.widget id_ = widget.attrs.get('id') or self.auto_id if id_: - attrs = attrs and flatatt(attrs) or '' + attrs = flatatt(attrs) if attrs else '' contents = format_html('<label for="{0}"{1}>{2}</label>', widget.id_for_label(id_), attrs, contents ) diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 2bd11d9f53..d421770093 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -119,7 +119,7 @@ class BaseFormSet(object): return self.management_form.cleaned_data[INITIAL_FORM_COUNT] else: # Use the length of the initial data if it's there, 0 otherwise. - initial_forms = self.initial and len(self.initial) or 0 + initial_forms = len(self.initial) if self.initial else 0 return initial_forms def _construct_forms(self): diff --git a/django/forms/widgets.py b/django/forms/widgets.py index e72ab014b8..aca4a457af 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -775,7 +775,7 @@ class MultiWidget(Widget): You'll probably want to use this class with MultiValueField. """ def __init__(self, widgets, attrs=None): - self.widgets = [isinstance(w, type) and w() or w for w in widgets] + self.widgets = [w() if isinstance(w, type) else w for w in widgets] super(MultiWidget, self).__init__(attrs) def render(self, name, value, attrs=None): |
