diff options
Diffstat (limited to 'django/forms/widgets.py')
| -rw-r--r-- | django/forms/widgets.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 88dc28d664..ce38bf00a5 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -104,6 +104,7 @@ class Media(object): getattr(combined, 'add_' + name)(getattr(other, '_' + name, None)) return combined + def media_property(cls): def _media(self): # Get the media property of the superclass, if it exists @@ -131,6 +132,7 @@ def media_property(cls): return base return property(_media) + class MediaDefiningClass(type): """ Metaclass for classes that can have media definitions. @@ -162,6 +164,7 @@ class SubWidget(object): args.append(self.choices) return self.parent_widget.render(*args) + class Widget(six.with_metaclass(MediaDefiningClass)): is_hidden = False # Determines whether this corresponds to an <input type="hidden">. needs_multipart_form = False # Determines does this widget need multipart form @@ -224,6 +227,7 @@ class Widget(six.with_metaclass(MediaDefiningClass)): """ return id_ + class Input(Widget): """ Base class for all <input> widgets (except type='checkbox' and @@ -279,10 +283,12 @@ class PasswordInput(TextInput): value = None return super(PasswordInput, self).render(name, value, attrs) + class HiddenInput(Input): input_type = 'hidden' is_hidden = True + class MultipleHiddenInput(HiddenInput): """ A widget that handles <input type="hidden"> for fields that have a list @@ -313,6 +319,7 @@ class MultipleHiddenInput(HiddenInput): return data.getlist(name) return data.get(name, None) + class FileInput(Input): input_type = 'file' needs_multipart_form = True @@ -327,6 +334,7 @@ class FileInput(Input): FILE_INPUT_CONTRADICTION = object() + class ClearableFileInput(FileInput): initial_text = ugettext_lazy('Currently') input_text = ugettext_lazy('Change') @@ -389,6 +397,7 @@ class ClearableFileInput(FileInput): return False return upload + class Textarea(Widget): def __init__(self, attrs=None): # The 'rows' and 'cols' attributes are required for HTML correctness. @@ -515,6 +524,7 @@ class Select(Widget): output.append(self.render_option(selected_choices, option_value, option_label)) return '\n'.join(output) + class NullBooleanSelect(Select): """ A Select Widget intended to be used with NullBooleanField. @@ -849,6 +859,7 @@ class SplitDateTimeWidget(MultiWidget): return [value.date(), value.time().replace(microsecond=0)] return [None, None] + class SplitHiddenDateTimeWidget(SplitDateTimeWidget): """ A Widget that splits datetime input into two <input type="hidden"> inputs. |
