Skip to content

Releases: stefanfoulis/django-phonenumber-field

8.0.0

24 Jun 13:48
Compare
Choose a tag to compare

What's Changed

Breaking changes

  • Remove PhoneNumberInternationalFallbackWidget by @francoisfreitag in #602

    Use phonenumber_field.widgets.RegionalPhoneNumberWidget instead.

  • Move validation from widgets to the form fields by @francoisfreitag in #603

    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.

Other changes

Full Changelog: 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:

7.3.0

29 Dec 14:31
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 7.2.0...7.3.0

7.2.0

05 Oct 06:57
Compare
Choose a tag to compare

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

New Contributors

Full Changelog: 7.1.0...7.2.0

7.1.0

26 Apr 20:43
Compare
Choose a tag to compare

What's Changed

Miscellaneous

New Contributors

Full Changelog: 7.0.2...7.1.0

7.0.2

09 Jan 16:27
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 7.0.1...7.0.2

7.0.1

06 Dec 08:08
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 7.0.0...7.0.1

7.0.0

07 Sep 15:10
Compare
Choose a tag to compare

Possible backward incompatibilities

  • RegionalPhoneNumberWidget becomes the default widget for the formfields.PhoneNumberField.
  • The formfields.PhoneNumberField no longer sets the input_type attribute of its widget to tel. That behavior did not make sense for the existing PhoneNumberPrefixWidget and was dropped.
  • PhoneNumberInternationalFallbackWidget will be replaced by RegionalPhoneNumberWidget in the next major version. It is deprecated until the next major release.

Changes

  • Restore PhoneNumberPrefixWidget number input on form errors by @francoisfreitag in #520

    Fixes a bug where the form field prepare_value() transformed the PhoneNumber value to an str in the national format, but PhoneNumberPrefixWidget expects its value to be a PhoneNumber. formfields.PhoneNumberField now represents its value with a PhoneNumber 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 005769c. Switching to the widget allows users to opt-out from that behavior (e.g. by using a TextInput widget), whereas prepare_value() forced the conversion to the national string format.

  • Set PhoneNumberInternationalFallbackWidget input_type to tel by @francoisfreitag in #521

    Previously, the <input> from the PhoneNumberInternationalFallbackWidget was set to text.

  • Evolve PhoneNumberInternationalWidget to RegionalPhoneNumberWidget by @francoisfreitag in #529

    The newer widget gives more control over the display of phone numbers. The behavior of PhoneNumberInternaltionalWidget can be retained by setting PHONENUMBER_DEFAULT_FORMAT="INTERNATIONAL", which is why PhoneNumberInternaltionalWidget will be removed in the next major version.

  • Add Dutch translation by @thijskramer in #532

  • Add documentation and host it at readthedocs.org by @francoisfreitag in #531

  • Prefer SUPPORTED_REGIONS over _AVAILABLE_REGION_CODES by @francoisfreitag in #528

New Contributors

Full Changelog: 6.4.0...7.0.0

6.4.0

28 Aug 14:08
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 6.3.0...6.4.0

6.3.0

17 Jun 09:38
Compare
Choose a tag to compare

What's Changed

Full Changelog: 6.2.0...6.3.0

6.2.0

14 Jun 12:40
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 6.1.0...6.2.0