I
I
Ilya Chichak2017-04-19 13:01:41
Django
Ilya Chichak, 2017-04-19 13:01:41

How to make a table with checkboxes and additional information in a form?

There is a ModelForm, in which one of the ModelMultipleChoiceField fields with a CheckboxSelectMultiple widget.
Is it possible to somehow display this field as a table, in the additional columns of which would be the data of the queryset objects of the field?
For example:

class Listener(models.Model):
    created = models.DateTimeField(default=timezone.now)
    ...

class CreateExtGroupFrom(forms.ModelForm):
    listeners = forms.ModelMultipleChoiceField(
        queryset=ext_models.ExtListener.objects.filter(...),
        widget=forms.CheckboxSelectMultiple(),
    )

to end up with something like this:
|    | Listener  | created  |
-----------------------------
| [] | listener1 | 1.1.2017 |
| [] | listener2 | 2.1.2017 |

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question