Guest User

Untitled

a guest
Nov 18th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. class SupervisorForm(forms.Form):
  2. is_manager = forms.BooleanField(label=_("manager"), required=False)
  3.  
  4. <input type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} />
  5.  
  6. class SwitchWidgetCheckboxInput(ClearableFileInput):
  7. template_name = 'utils/SwitchWidgetCheckboxInput.html'
  8.  
  9. @property
  10. def media(self):
  11. js = ("utils/switch_widget_checkbox_input/SwitchWidgetCheckboxInput.js",)
  12. css = {'all': ("utils/switch_widget_checkbox_input/SwitchWidgetCheckboxInput.css",)}
  13. return forms.Media(js=js, css=css)
  14.  
  15. def render(self, name, value, attrs=None, renderer=None):
  16. """
  17. Returns this Widget rendered as HTML, as a Unicode string.
  18. """
  19. context = self.get_context(name, value, attrs)
  20. return self._render(self.template_name, context, renderer)
  21.  
  22. class SupervisorForm(forms.Form):
  23. is_manager = forms.BooleanField(label=_("manager"), required=False, widget=SwitchWidgetCheckboxInput)
  24.  
  25. <input type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} />
  26.  
  27. <input type="checkbox" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} />
Add Comment
Please, Sign In to add comment