Changes between Initial Version and Version 1 of Ticket #35409


Ignore:
Timestamp:
Apr 26, 2024, 11:43:56 AM (7 months ago)
Author:
Natalia Bidart
Comment:

Hello Marc! Thank you for your report. In order to do a proper triage of this ticket, I need your help with the following:

  1. Could you please confirm that this issue is present in the main branch of the Django project?
  2. Could you please provide a minimal reproducer with the form you used and template?

A few things to note:

  • Django 3.2 is no longer supported and Django 4.2 is on security-fixes-only support mode.
  • Django 4.1 introduced some transitional form renderer classes to ease migration to 5.0 where there is a change in how the forms are rendered by default (using <div>), please check the release notes for 4.1 and 5.0.

I tried to reproduce this with no success. My form is as follows:

from django import forms


class MyForm(forms.Form):
    recipients = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple)

    def __init__(self, *a, **kw):
        super().__init__(*a, **kw)
        recipient_choices = [(i, f"User {i} with email {i}@something") for i in range(5)]
        self.fields['recipients'].choices = recipient_choices

And when rendering it with {{ form }} in a Django template, I get a nice looking form:

Recipients:

Closing as worksforme until a minimal reproducer or more information is provided.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35409

    • Property Component UncategorizedForms
    • Property Resolutionworksforme
    • Property Status newclosed
    • Property Type UncategorizedBug
  • Ticket #35409 – Description

    initial v1  
    22
    33In the form definition:
     4{{{
    45recipients = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple)
     6}}}
    57
    6 In __init__:
     8In `__init__`:
     9{{{
    710self.fields['recipients'].choices = recipient_choices
     11}}}
    812
    913This has worked since 2009, but Django 4.2.x has broken it as it does not insert line breaks between the recipients and the list is a jumbled mess. I've coded around it by using the SelectMultiple widget, which still allows editing of the list, but not in obvious ways to my users, and is thus unacceptable.
Back to Top