django.forms. - python examples

Here are the examples of the python api django.forms. taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

3 View Complete Implementation : process_forms.py
Copyright MIT License
Author : hellno
    def generate_fields_for_labels(self, labels):
        for i, label in enumerate(labels):
            widget = forms.CheckboxInput(
                attrs={'accesskey': str(i + 1), 'id': f'label_select_{i+1}'})
            label_str = f'{i+1}: {label}' if i < 10 else label
            self.fields[label] = forms.BooleanField(label=label_str, required=False, initial=False, widget=widget)

3 View Complete Implementation : process_forms.py
Copyright MIT License
Author : hellno
    def generate_fields_for_labels(self, labels):
        for i, label in enumerate(labels):
            label_str = f'{label} (Key: {i+1})' if i < 10 else label
            widget = forms.CheckboxInput(
                attrs={'accesskey': str(i + 1), 'id': f'label_select_{i+1}',
                       'type': 'checkbox', 'clast': 'checkbox', 'data-toggle': 'toggle',
                       'data-off': 'Image 1', 'data-on': 'Image 2',
                       'data-onstyle': 'warning', 'data-offstyle': 'info'})
            self.fields[label] = forms.BooleanField(label=label_str, required=False, initial=False, widget=widget)