chore(deps): update dependency django-phonenumber-field to v8
This MR contains the following updates:
Package | Change | Age | Adoption | Passing | Confidence |
---|---|---|---|---|---|
django-phonenumber-field (changelog) |
~=7.3 -> ~=8.1
|
⚠️ WarningSome dependencies could not be looked up. Check the Dependency Dashboard for more information.
Release Notes
stefanfoulis/django-phonenumber-field (django-phonenumber-field)
v8.1.0
What's Changed
-
Remove non-geo phone numbers from the SplitPhoneNumberWidget by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/614
The phone number prefix field allows to select a world region, and maps to its prefix (e.g. get
+33
for France). It was incorrectly offering regions reserved for very specific use and which cannot be mapped to a world region. Example prefixes include 800 (Universal International Freephone Service), 808 (Universal International Shared Cost Number), 870 (Global Mobile Satellite System), and others. If such a prefix was selected, the field would plainly crash. Since the prefix purpose is to let users select a world region, prevent from selecting non-geo options in the prefix list. Please open an issue if you would like to see this use case supported. -
Document how to customize SplitPhoneNumberField fields by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/631
-
Clarify translations context for error messages by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/613
Compatibility
- Add support for Django 5.2 by @adamchainz in https://github.com/stefanfoulis/django-phonenumber-field/pull/630
- Add support for Django 5.1 by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/616
- Add support for Python 3.13 by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/617
- Drop support for Django 3.2 by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/615
- Drop python3.8 from test matrix and metadata by @francoisfreitag in https://github.com/stefanfoulis/django-phonenumber-field/pull/626
Full Changelog: https://github.com/stefanfoulis/django-phonenumber-field/compare/8.0.0...8.1.0
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:
Configuration
-
If you want to rebase/retry this MR, check this box
This MR has been generated by Renovate Bot.