PhoneNumberPrefixWidget, problem with 'required'
See original GitHub issueHi,
Thanks for django-phonenumber-field
When I am using django-phonenumber-field widget with required=True
, it works fine but if I change to required=False
then also it is not allow to submit empty.
What I found is in class PhoneNumberPrefixWidget
and in method ‘value_from_datadict’, even when there is no data it will return dot(.) and that will be raise an validation error
If I change like this, then it works
def value_from_datadict(self, data, files, name):
values = super(PhoneNumberPrefixWidget, self).value_from_datadict(
data, files, name)
if all(values):
return '%s.%s' % tuple(values)
return ''
But if you try above code with required=True
then it will throw error because there is no required message is set but this can be set on form level for now, by setting error_messages
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
Django PhoneNumberField library giving problem when using ...
But when I access the field and give bootstrap class, the layout changes. It displays PhoneNumberPrefixWidget in one line and PhoneNumberField ...
Read more >django-phonenumber-field - Bountysource
I had problems getting a form with the widget to work. ... How do I style the PhoneNumberPrefixWidget since it uses multi widget...
Read more >10 Django tutorials | Setup International Phone number widget ...
An error occurred while retrieving sharing information. Please try again later. 0:00. 0:00 / 16:56•Watch full video
Read more >Display a MultiWidget Form manually in template - Reddit
The issue is in the PhoneNumberField + PhoneNumberPrefixWidget. ... After I have learned Django for Web Backends, I need suggestions for ...
Read more >django-phonenumber-field - PyPI
Skip to main content. Switch to mobile version. Warning Some features may not work without JavaScript. Please try enabling it if you encounter...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also experienced the same problem and solved it temporarily by extending the
PhoneNumberPrefixWidget
and overwriting thevalue_from_datadict
method in my code like this:Should be resolved with https://github.com/stefanfoulis/django-phonenumber-field/pull/512, available in the next release.