def test_model_choice_field(self):
        SomeModel2.objects.create(some_field='Meh')
        SomeModel2.objects.create(some_field='Bah')

        class MultiModelForm(forms.Form):
            mods = forms.ModelMultipleChoiceField(queryset=SomeModel2.objects.all())

        rendered = MultiModelForm(data={'mods': [1, 2]})['mods'].as_hidden()
        self.assertHTMLEqual(rendered, """
        <input type="hidden" name="mods" value="1" id="id_mods_0">
        <input type="hidden" name="mods" value="2" id="id_mods_1">
        """)
ModelChoiceField and ModelMultipleChoiceField
dataset/ETHPy150Open gregmuellegger/django-floppyforms/tests/test_modelforms.py/ModelMultipleChoiceFieldTests.test_model_choice_field