Previously, the widgets were validating the phone number, leaving no room for the django regular validation procedure. If you performed custom validation on PhoneNumberFields, see the migration guide below.
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 Formclean_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
Note: Releases are now tracked using
GitHub releases <https://github.com/stefanfoulis/django-phonenumber-field/releases>__.
This document remains for historical purposes.
6.1.0 (2022-01-12)
Make formfields.PhoneNumberField honor PHONENUMBER_DEFAULT_REGION
Use PHONENUMBER_DEFAULT_REGION for example phone number in form field errors.
Add support for Django 4.0
Add Persian (farsi) translations.
Update uk_AR translations
Backwards incompatible changes
Drop support for Python 3.6
6.0.0 (2021-10-20)
Add support for Python 3.10
Update Czech, Dutch and pt_BR translations
Backwards incompatible changes
formfields.PhoneNumberField with a region now display national phone
numbers in the national format instead of PHONENUMBER_DEFAULT_FORMAT.
International numbers are displayed in the PHONENUMBER_DEFAULT_FORMAT.
5.2.0 (2021-05-31)
Lazy load formfields.PhoneNumberField translation for invalid data.
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
coverage: 97.784%. remained the same
when pulling f31d9dcbefb182e8c142f7c9a9f7baec80499371 on dependabot/pip/django-phonenumber-field-approx-eq-8.0.0
into 9f60905ce7dd8104df4dd1246c5d2be5ed8c7d15 on master.
Updates the requirements on django-phonenumber-field to permit the latest version.
Release notes
Sourced from django-phonenumber-field's releases.
Changelog
Sourced from django-phonenumber-field's changelog.
... (truncated)
Commits
f7765f4
docs: Fix representation of serializerb255326
Add validate_phonenumber to allow short numbersb8d1886
Rename test_value_from_datadict to test_example_numbers9923578
Move validation from widgets to the form fieldse491d09
Drop support for Django 4.1ef1e728
Remove PhoneNumberInternationalFallbackWidget4484533
update Italian localeee1dd71
Make PhoneNumberPrefixSelect use the provided regioncb83645
Merge pull request #590 from francoisfreitag/mob1f355d
Merge pull request #591 from stefanfoulis/dependabot/github_actions/actions/u...Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show