Skip to content

Added support for Django 5.2. #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next Release
* Added Python 3.13 support.
* Added support for Django 5.2.

## 2024.10 (2024-10-05)
* Added support for Django 5.1.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ classifiers=[
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Framework :: Django :: 5.2",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
Expand Down
2 changes: 1 addition & 1 deletion tests/results/field_with_buttons_failing.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="mb-3"><label class=" form-label requiredField" for="id_email">Email<span
class="asteriskField">*</span></label>
<div>
<div class="input-group"><input class="form-control inputtext is-invalid textInput textinput"
<div class="input-group"><input class="form-control inputtext is-invalid textInput textinput" aria-describedby="id_email_error"
id="id_email" maxlength="20" name="email" required type="text" aria-invalid="true"><button
class="btn btn-outline-secondary" type="button">Go!</button></div>
<p class="mb-0 text-danger" id="error_1_id_email"><small><strong>This field is
Expand Down
14 changes: 14 additions & 0 deletions tests/results/field_with_buttons_failing_lt52.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<form method="post">
<div class=" col-md">
<div class="mb-3"><label class=" form-label requiredField" for="id_email">Email<span
class="asteriskField">*</span></label>
<div>
<div class="input-group"><input class="form-control inputtext is-invalid textInput textinput"
id="id_email" maxlength="20" name="email" required type="text" aria-invalid="true"><button
class="btn btn-outline-secondary" type="button">Go!</button></div>
<p class="mb-0 text-danger" id="error_1_id_email"><small><strong>This field is
required.</strong></small></p>
</div>
</div>
</div>
</form>
1 change: 1 addition & 0 deletions tests/results/test_clearable_file_field_failing.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</label>
<div class="is-invalid">
<input
aria-describedby="id_clearable_file_error"
type="file"
name="clearable_file"
class="form-control is-invalid"
Expand Down
21 changes: 21 additions & 0 deletions tests/results/test_clearable_file_field_failing_lt52.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<form method="post" enctype="multipart/form-data">
<div id="div_id_clearable_file" class="mb-3">
<label for="id_clearable_file" class="form-label requiredField">
Clearable file
<span class="asteriskField">*</span>
</label>
<div class="is-invalid">
<input
type="file"
name="clearable_file"
class="form-control is-invalid"
id="id_clearable_file"
required
aria-invalid="true"
>
<span id="error_1_id_clearable_file" class="invalid-feedback">
<strong>This field is required.</strong>
</span>
</div>
</div>
</form>
1 change: 1 addition & 0 deletions tests/results/test_file_field_failing.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</label>
<div class="is-invalid">
<input
aria-describedby="id_file_field_error"
type="file"
name="file_field"
class="form-control is-invalid"
Expand Down
21 changes: 21 additions & 0 deletions tests/results/test_file_field_failing_lt52.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<form method="post" enctype="multipart/form-data">
<div id="div_id_file_field" class="mb-3">
<label for="id_file_field" class="form-label requiredField">
File field
<span class="asteriskField">*</span>
</label>
<div class="is-invalid">
<input
type="file"
name="file_field"
class="form-control is-invalid"
id="id_file_field"
required
aria-invalid="true"
>
<span id="error_1_id_file_field" class="invalid-feedback">
<strong>This field is required.</strong>
</span>
</div>
</div>
</form>
4 changes: 2 additions & 2 deletions tests/results/test_floating_field_failing.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form method="post" >
<div id="div_id_text_area" class="form-floating mb-3">
<textarea name="text_area" cols="40" rows="10" placeholder="text_area" class="textarea form-control is-invalid" required id="id_text_area" aria-invalid="true">
<textarea aria-describedby="id_text_area_error" name="text_area" cols="40" rows="10" placeholder="text_area" class="textarea form-control is-invalid" required id="id_text_area" aria-invalid="true">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These ones adding references to errors I'm happy with. That was a new feature in 5.2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/django-crispy-forms/crispy-bootstrap5/blob/main/crispy_bootstrap5/templates/bootstrap5/layout/field_errors.html This (and the block version) will need updating so that the new aria-describedby has a target to reference.

See error when testing with the 'wave' accessibility checker:

image

</textarea>
<label for="id_text_area">
Text area<span class="asteriskField">*</span>
Expand All @@ -10,7 +10,7 @@
</span>
</div>
<div id="div_id_select_input" class="form-floating mb-3">
<select name="select_input" placeholder="select_input" class="select form-select is-invalid" id="id_select_input" aria-invalid="true">
<select aria-describedby="id_select_input_error" name="select_input" placeholder="select_input" class="select form-select is-invalid" id="id_select_input" aria-invalid="true">
<option value="1">Option one</option>
<option value="2">Option two</option>
<option value="3">Option three</option>
Expand Down
25 changes: 25 additions & 0 deletions tests/results/test_floating_field_failing_lt52.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<form method="post" >
<div id="div_id_text_area" class="form-floating mb-3">
<textarea name="text_area" cols="40" rows="10" placeholder="text_area" class="textarea form-control is-invalid" required id="id_text_area" aria-invalid="true">
</textarea>
<label for="id_text_area">
Text area<span class="asteriskField">*</span>
</label>
<span id="error_1_id_text_area" class="invalid-feedback">
<strong>This field is required.</strong>
</span>
</div>
<div id="div_id_select_input" class="form-floating mb-3">
<select name="select_input" placeholder="select_input" class="select form-select is-invalid" id="id_select_input" aria-invalid="true">
<option value="1">Option one</option>
<option value="2">Option two</option>
<option value="3">Option three</option>
</select>
<label for="id_select_input">
Select input<span class="asteriskField">*</span>
</label>
<span id="error_1_id_select_input" class="invalid-feedback">
<strong>This field is required.</strong>
</span>
</div>
</form>
2 changes: 1 addition & 1 deletion tests/results/test_switch.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form method="post">
<div id="div_id_is_company" class="mb-3 form-check form-switch">
<div class="">
<input type="checkbox" name="is_company" class="checkboxinput form-check-input" role="checkbox" id="id_is_company" />
<input aria-describedby="id_is_company_helptext" type="checkbox" name="is_company" class="checkboxinput form-check-input" role="checkbox" id="id_is_company" />
<label for="id_is_company" class="form-check-label">company</label>
<div id="id_is_company_helptext" class="form-text">is_company help text</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion tests/results/test_switch_horizontal.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form class="form-horizontal" method="post">
<div id="div_id_is_company" class="mb-3 form-check form-switch row">
<div class="offset-lg-2 col-lg-8">
<input type="checkbox" name="is_company" class="checkboxinput form-check-input" role="checkbox" id="id_is_company" />
<input type="checkbox" aria-describedby="id_is_company_helptext" name="is_company" class="checkboxinput form-check-input" role="checkbox" id="id_is_company" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is a bit odd. aria-describedby for help text has been about for a while. Needs some investigation to understand why this is changing for us in 5.2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bisected to django/django@1e05431

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous to django/django@1e05431 Django looked at the field's help text (self.field.help_text), but this got changed to looking at the BoundField's help text (self.help_text). That's impacting this test here as the help text is set like this:

form["is_company"].help_text = "is_company help text"

Rather than when setting the field on the form:

class MyForm(forms.Form):
   my_field = forms.CharField(help_text="...", ...)

I think, that's ok as we would expect help text to be referenced with an aria_describedby, but it is a change that I had not spotted when working on the patch to Django.

@sarahboyce -- sorry for the ping. I spotted this change, and would appreciate your thought with your fellow hat on. I think it's likely ok but wondered if you could give a second opinion on if we need to do anything further at django/django for this behaviour change?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, that's ok as we would expect help text to be referenced with an aria_describedby, but it is a change that I had not spotted when working on the patch to Django.

I think this is now more correct.
I don't think we need to add further docs, we could add a test for this explicitly so we do not revert this behavior

<label for="id_is_company" class="form-check-label">company</label>
<div id="id_is_company_helptext" class="form-text">is_company help text</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions tests/results/test_switch_horizontal_lt52.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<form class="form-horizontal" method="post">
<div id="div_id_is_company" class="mb-3 form-check form-switch row">
<div class="offset-lg-2 col-lg-8">
<input type="checkbox" name="is_company" class="checkboxinput form-check-input" role="checkbox" id="id_is_company" />
<label for="id_is_company" class="form-check-label">company</label>
<div id="id_is_company_helptext" class="form-text">is_company help text</div>
</div>
</div>
<div id="div_id_first_name" class="mb-3 row">
<label for="id_first_name" class="col-form-label col-lg-2 pt-0 requiredField">first name<span class="asteriskField">*</span> </label>
<div class="col-lg-8"><input type="text" name="first_name" maxlength="5" class="textinput textInput inputtext form-control" required id="id_first_name" /></div>
</div>
</form>
9 changes: 9 additions & 0 deletions tests/results/test_switch_lt52.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<form method="post">
<div id="div_id_is_company" class="mb-3 form-check form-switch">
<div class="">
<input type="checkbox" name="is_company" class="checkboxinput form-check-input" role="checkbox" id="id_is_company" />
<label for="id_is_company" class="form-check-label">company</label>
<div id="id_is_company_helptext" class="form-text">is_company help text</div>
</div>
</div>
</form>
8 changes: 5 additions & 3 deletions tests/results/test_tabular_formset_layout_failing.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,26 @@
<tr>
<td class="mb-3" id="div_id_form-0-is_company"><input class="checkboxinput form-check-input"
id="id_form-0-is_company" name="form-0-is_company" type="checkbox"></td>
<td class="mb-3" id="div_id_form-0-email"><input aria-describedby="id_form-0-email_helptext"
<td class="mb-3" id="div_id_form-0-email"><input aria-describedby="id_form-0-email_helptext id_form-0-email_error"
class="form-control inputtext is-invalid textInput textinput" id="id_form-0-email" aria-invalid="true"
maxlength="30" name="form-0-email" type="text"><span class="invalid-feedback"
id="error_1_id_form-0-email"><strong>This field is required.</strong></span><div
class="form-text" id="id_form-0-email_helptext">Insert your email</div></td>
<td class="mb-3" id="div_id_form-0-password1"><input class="form-control is-invalid textInput textinput"
aria-describedby="id_form-0-password1_error"
id="id_form-0-password1" maxlength="30" name="form-0-password1" type="password" aria-invalid="true"><span
class="invalid-feedback" id="error_1_id_form-0-password1"><strong>This field is
required.</strong></span></td>
<td class="mb-3" id="div_id_form-0-password2"><input class="form-control is-invalid textInput textinput"
aria-describedby="id_form-0-password2_error"
id="id_form-0-password2" maxlength="30" name="form-0-password2" type="password" aria-invalid="true"><span
class="invalid-feedback" id="error_1_id_form-0-password2"><strong>This field is
required.</strong></span></td>
<td class="mb-3" id="div_id_form-0-first_name"><input
<td class="mb-3" id="div_id_form-0-first_name"><input aria-describedby="id_form-0-first_name_error"
class="form-control inputtext is-invalid textInput textinput" id="id_form-0-first_name"
maxlength="5" name="form-0-first_name" type="text" aria-invalid="true"><span class="invalid-feedback"
id="error_1_id_form-0-first_name"><strong>This field is required.</strong></span></td>
<td class="mb-3" id="div_id_form-0-last_name"><input
<td class="mb-3" id="div_id_form-0-last_name"><input aria-describedby="id_form-0-last_name_error"
class="form-control inputtext is-invalid textInput textinput" id="id_form-0-last_name"
maxlength="5" name="form-0-last_name" type="text" aria-invalid="true"><span class="invalid-feedback"
id="error_1_id_form-0-last_name"><strong>This field is required.</strong></span></td>
Expand Down
87 changes: 87 additions & 0 deletions tests/results/test_tabular_formset_layout_failing_lt52.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<form method="post">
<div><input id="id_form-TOTAL_FORMS" name="form-TOTAL_FORMS" type="hidden" value="1"><input
id="id_form-INITIAL_FORMS" name="form-INITIAL_FORMS" type="hidden" value="0"><input
id="id_form-MIN_NUM_FORMS" name="form-MIN_NUM_FORMS" type="hidden"><input id="id_form-MAX_NUM_FORMS"
name="form-MAX_NUM_FORMS" type="hidden"></div>
<table class="table table-sm table-striped">
<thead>
<tr>
<th class="" for="id_form-0-is_company">company</th>
<th class="requiredField" for="id_form-0-email">email<span class="asteriskField">*</span>
</th>
<th class="requiredField" for="id_form-0-password1">password<span
class="asteriskField">*</span></th>
<th class="requiredField" for="id_form-0-password2">re-enter password<span
class="asteriskField">*</span></th>
<th class="requiredField" for="id_form-0-first_name">first name<span
class="asteriskField">*</span></th>
<th class="requiredField" for="id_form-0-last_name">last name<span
class="asteriskField">*</span></th>
<th class="requiredField" for="id_form-0-datetime_field">date time<span
class="asteriskField">*</span></th>
</tr>
</thead>
<tbody>
<tr class="d-none empty-form">
<td class="mb-3" id="div_id_form-__prefix__-is_company"><input
class="checkboxinput form-check-input" id="id_form-__prefix__-is_company"
name="form-__prefix__-is_company" type="checkbox"></td>
<td class="mb-3" id="div_id_form-__prefix__-email"><input
class="form-control inputtext textInput textinput" id="id_form-__prefix__-email" maxlength="30"
name="form-__prefix__-email" type="text" aria-describedby="id_form-__prefix__-email_helptext">
<div class="form-text" id="id_form-__prefix__-email_helptext">Insert your email</div></td>
<td class="mb-3" id="div_id_form-__prefix__-password1"><input class="form-control textInput textinput"
id="id_form-__prefix__-password1" maxlength="30" name="form-__prefix__-password1"
type="password"></td>
<td class="mb-3" id="div_id_form-__prefix__-password2"><input class="form-control textInput textinput"
id="id_form-__prefix__-password2" maxlength="30" name="form-__prefix__-password2"
type="password"></td>
<td class="mb-3" id="div_id_form-__prefix__-first_name"><input
class="form-control inputtext textInput textinput" id="id_form-__prefix__-first_name"
maxlength="5" name="form-__prefix__-first_name" type="text"></td>
<td class="mb-3" id="div_id_form-__prefix__-last_name"><input
class="form-control inputtext textInput textinput" id="id_form-__prefix__-last_name"
maxlength="5" name="form-__prefix__-last_name" type="text"></td>
<td class="mb-3" id="div_id_form-__prefix__-datetime_field"><input class="dateinput form-control"
id="id_form-__prefix__-datetime_field_0" name="form-__prefix__-datetime_field_0"
type="text"><input class="form-control timeinput" id="id_form-__prefix__-datetime_field_1"
name="form-__prefix__-datetime_field_1" type="text"></td>
</tr>
<div class="alert alert-block alert-danger">
<ul class="m-0">
<li>Passwords dont match</li>
</ul>
</div>
<tr>
<td class="mb-3" id="div_id_form-0-is_company"><input class="checkboxinput form-check-input"
id="id_form-0-is_company" name="form-0-is_company" type="checkbox"></td>
<td class="mb-3" id="div_id_form-0-email"><input aria-describedby="id_form-0-email_helptext"
class="form-control inputtext is-invalid textInput textinput" id="id_form-0-email" aria-invalid="true"
maxlength="30" name="form-0-email" type="text"><span class="invalid-feedback"
id="error_1_id_form-0-email"><strong>This field is required.</strong></span><div
class="form-text" id="id_form-0-email_helptext">Insert your email</div></td>
<td class="mb-3" id="div_id_form-0-password1"><input class="form-control is-invalid textInput textinput"
id="id_form-0-password1" maxlength="30" name="form-0-password1" type="password" aria-invalid="true"><span
class="invalid-feedback" id="error_1_id_form-0-password1"><strong>This field is
required.</strong></span></td>
<td class="mb-3" id="div_id_form-0-password2"><input class="form-control is-invalid textInput textinput"
id="id_form-0-password2" maxlength="30" name="form-0-password2" type="password" aria-invalid="true"><span
class="invalid-feedback" id="error_1_id_form-0-password2"><strong>This field is
required.</strong></span></td>
<td class="mb-3" id="div_id_form-0-first_name"><input
class="form-control inputtext is-invalid textInput textinput" id="id_form-0-first_name"
maxlength="5" name="form-0-first_name" type="text" aria-invalid="true"><span class="invalid-feedback"
id="error_1_id_form-0-first_name"><strong>This field is required.</strong></span></td>
<td class="mb-3" id="div_id_form-0-last_name"><input
class="form-control inputtext is-invalid textInput textinput" id="id_form-0-last_name"
maxlength="5" name="form-0-last_name" type="text" aria-invalid="true"><span class="invalid-feedback"
id="error_1_id_form-0-last_name"><strong>This field is required.</strong></span></td>
<td class="mb-3" id="div_id_form-0-datetime_field"><input class="dateinput form-control is-invalid"
id="id_form-0-datetime_field_0" name="form-0-datetime_field_0" type="text" aria-invalid="true"><input
class="form-control is-invalid timeinput" id="id_form-0-datetime_field_1"
name="form-0-datetime_field_1" type="text" aria-invalid="true"><span class="invalid-feedback"
id="error_1_id_form-0-datetime_field"><strong>This field is required.</strong></span></td>
</tr>
</tbody>
</table>
</form>
Loading