Update dependency django-phonenumber-field to v8
This MR contains the following updates:
Package | Type | Update | Change |
---|---|---|---|
django-phonenumber-field (changelog) | dependencies | major |
^6.1 -> ^8.0
|
Release Notes
stefanfoulis/django-phonenumber-field
v8.0.0
What's Changed
Breaking changes
-
Remove
PhoneNumberInternationalFallbackWidget
by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/602Use
phonenumber_field.widgets.RegionalPhoneNumberWidget
instead. -
Move validation from widgets to the form fields by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/603
Previously, the widgets were validating the phone number, leaving no room for the django regular validation procedure. If you performed custom validation on
PhoneNumberField
s, see the migration guide below.
Other changes
- Drop support for Django 4.1 by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/604
- docs: Fix representation of serializer by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/607
Full Changelog: https://github.com/stefanfoulis/django-phonenumber-field/compare/7.3.0...8.0.0
Migration guide
Previously, the widgets handled part of the validation. That behavior prevents overriding validation in form fields, as widgets were casting the value into a PhoneNumber
object, validating it in the process.
Following the MultiValueField
implementation from Django (and MultiWidget
), the widget now handles the presentation logic, but makes
no attempt at validation. The new SplitPhoneNumberField
handles the logic of validating the region choice and the number, and the PhoneNumberPrefixWidget
simply dispatches the region and number data to the appropriate widget.
In order to retain backward compatibility, now that the validate_international_phonenumber
actually comes into play, its error code has been changed to invalid
, so that the custom error message for invalid shows.
validate_international_phonenumber
Review uses of the invalid_phone_number
error code. You’ll probably want to replace them with invalid
. Given that the validator usually did not come into play, you shouldn’t find many uses.
PhoneNumberField
with RegionalPhoneNumberWidget
Move the custom validation occurs in the Django Form
clean_FIELD()
(or clean()
), and no changes should be noticeable.
PhoneNumberField
with PhoneNumberPrefixWidget
Use the SplitPhoneNumberField
instead. Error messages will change slightly and should be more precise (whether the region is not part of
the choices, or the number cannot be interpreted in the selected region).
For more examples, take a look at tests.test_formfields.SplitPhoneNumberFieldTest
.
Make sure GitHub loads the diff for file tests/test_formfields.py
The following tests should cover most use cases:
v7.3.0
What's Changed
- Add support for Django 5.0 by @adamchainz in https://github.com/stefanfoulis/django-phonenumber-field/pull/582
- Document phone number extension handling by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/583
- Make PhoneNumberPrefixSelect use the provided region by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/593
- Update Italian locale by @RuggeroFabbiano in https://github.com/stefanfoulis/django-phonenumber-field/pull/594
New Contributors
- @RuggeroFabbiano made their first contribution in https://github.com/stefanfoulis/django-phonenumber-field/pull/594
Full Changelog: https://github.com/stefanfoulis/django-phonenumber-field/compare/7.2.0...7.3.0
v7.2.0
This release should have been an 8.0 by the semver, as the DB converter for the model field can break working code.
What's Changed
-
BREAKING: Add a DB converter for the model field, fixing
values_list()
ofPhoneNumberField
s by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/559 -
Use public attributes and methods from phonenumbers by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/535
-
Remove zip_safe flag from setup.cfg by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/553
-
feat: Add mypy to CI by @last-partizan in https://github.com/stefanfoulis/django-phonenumber-field/pull/563
-
Drop support for Python 3.7 by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/561
-
Show support for Python 3.11 by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/570
-
Add support for Python 3.12 by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/576
New Contributors
- @dependabot made their first contribution in https://github.com/stefanfoulis/django-phonenumber-field/pull/555
- @last-partizan made their first contribution in https://github.com/stefanfoulis/django-phonenumber-field/pull/563
Full Changelog: https://github.com/stefanfoulis/django-phonenumber-field/compare/7.1.0...7.2.0
v7.1.0
What's Changed
- Update Norwegian translations by @ddabble in https://github.com/stefanfoulis/django-phonenumber-field/pull/549
- Drop support for Django 4.0, add Django 4.2 by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/550
Miscellaneous
- Update python and Django matrix by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/548
- Add common virtualenv locations to flake8 exclude and .gitignore by @blaedd in https://github.com/stefanfoulis/django-phonenumber-field/pull/547
- Document E164 lack of support for phone extensions by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/537
- Strip trailing line from beautifulsoup prettify output by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/551
New Contributors
- @blaedd made their first contribution in https://github.com/stefanfoulis/django-phonenumber-field/pull/547
- @ddabble made their first contribution in https://github.com/stefanfoulis/django-phonenumber-field/pull/549
Full Changelog: https://github.com/stefanfoulis/django-phonenumber-field/compare/7.0.2...7.1.0
v7.0.2
What's Changed
- Updated Swedish translations by @tjwalch in https://github.com/stefanfoulis/django-phonenumber-field/pull/544
New Contributors
- @tjwalch made their first contribution in https://github.com/stefanfoulis/django-phonenumber-field/pull/544
Full Changelog: https://github.com/stefanfoulis/django-phonenumber-field/compare/7.0.1...7.0.2
v7.0.1
What's Changed
- Allow multiple DRF is_valid calls to succeed by @phillipuniverse in https://github.com/stefanfoulis/django-phonenumber-field/pull/543
New Contributors
- @phillipuniverse made their first contribution in https://github.com/stefanfoulis/django-phonenumber-field/pull/543
Full Changelog: https://github.com/stefanfoulis/django-phonenumber-field/compare/7.0.0...7.0.1
v7.0.0
Possible backward incompatibilities
-
RegionalPhoneNumberWidget
becomes the default widget for theformfields.PhoneNumberField
. - The
formfields.PhoneNumberField
no longer sets theinput_type
attribute of its widget totel
. That behavior did not make sense for the existingPhoneNumberPrefixWidget
and was dropped. -
PhoneNumberInternationalFallbackWidget
will be replaced byRegionalPhoneNumberWidget
in the next major version. It is deprecated until the next major release.
Changes
-
Restore
PhoneNumberPrefixWidget
number input on form errors by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/520Fixes a bug where the form field
prepare_value()
transformed thePhoneNumber
value to anstr
in the national format, butPhoneNumberPrefixWidget
expects its value to be aPhoneNumber
.formfields.PhoneNumberField
now represents its value with aPhoneNumber
object, giving widgets more control on how to display the value.That behavior prompted the change to
PhoneNumberInternationalFallbackWidget
becoming the default widget, to preserve the behavior established in https://github.com/stefanfoulis/django-phonenumber-field/commit/005769cf39323e5b23710783f45befb546672cd6. Switching to the widget allows users to opt-out from that behavior (e.g. by using aTextInput
widget), whereasprepare_value()
forced the conversion to the national string format. -
Set
PhoneNumberInternationalFallbackWidget
input_type
totel
by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/521Previously, the
<input>
from thePhoneNumberInternationalFallbackWidget
was set totext
. -
Evolve
PhoneNumberInternationalWidget
toRegionalPhoneNumberWidget
by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/529The newer widget gives more control over the display of phone numbers. The behavior of
PhoneNumberInternaltionalWidget
can be retained by settingPHONENUMBER_DEFAULT_FORMAT="INTERNATIONAL"
, which is whyPhoneNumberInternaltionalWidget
will be removed in the next major version. -
Add Dutch translation by @thijskramer in https://github.com/stefanfoulis/django-phonenumber-field/pull/532
-
Add documentation and host it at readthedocs.org by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/531
-
Prefer
SUPPORTED_REGIONS
over_AVAILABLE_REGION_CODES
by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/528
New Contributors
- @thijskramer made their first contribution in https://github.com/stefanfoulis/django-phonenumber-field/pull/532
Full Changelog: https://github.com/stefanfoulis/django-phonenumber-field/compare/6.4.0...7.0.0
Configuration
-
If you want to rebase/retry this MR, click this checkbox.
This MR has been generated by Renovate Bot.