Guest User

Untitled

a guest
Oct 19th, 2020
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. class ToggleWidget(forms.widgets.CheckboxInput):
  2.   class Media:
  3.     css = {
  4.       "all": ("https://cdn.jsdelivr.net/gh/gitbrent/[email protected]/css/bootstrap4-toggle.min.css",)
  5.     }
  6.     js = ("https://cdn.jsdelivr.net/gh/gitbrent/[email protected]/js/bootstrap4-toggle.min.js",)
  7.  
  8.  
  9. class MyForm(forms.Form):
  10.   toggle_field = forms.BooleanField(required=False, widget=ToggleWidget())
  11.  
  12. """
  13. Template code:
  14. <form method="post">
  15. {% csrf_token%}
  16. <ul>
  17.        <li style="list-style-type:none;">
  18.            <div class="fieldWrapper">
  19.                {{ form.toggle_field.errors }}
  20.                {{ form.toggle_field.label_tag }}
  21.                {{ form.toggle_field }}
  22.            </div>
  23.        </li>
  24. </ul>
  25. <input type="submit" value="Update">
  26. </form>
  27. """
Add Comment
Please, Sign In to add comment