VeryApt / django-phone-field

Lightweight model and form field for phone numbers in Django
GNU General Public License v3.0
52 stars 13 forks source link

null=True in PhoneField throws widget exception #7

Closed atbigelow closed 5 years ago

atbigelow commented 5 years ago

Having null=True in a CharField and child fields sets an 'empty_value' key in the kwargs for the widget. You can see this logic in https://github.com/django/django/blob/stable/2.1.x/django/db/models/fields/__init__.py#L1091

But empty_value is NOT an argument for MultiValueField as seen here https://github.com/django/django/blob/stable/2.1.x/django/forms/fields.py#L971

My links are for 2.1.x but also refers to 2.2.x (which I am using).

Current workaround is to just not use null=True.

va-andrew commented 5 years ago

Thanks for the report! Django docs discourage setting null=True for CharFields and their descendants, but we shouldn't be causing an exception. Just released 1.7.1 with a fix.