I'm making a Django form to update users membership to a website. I want to be able to store phone numbers. I found django-phonenumber-field which is great. The only problem is that the form I created for the user to enter their phone number is too specific. If the user doesn't enter their number as "+99999999" then they get an input error. I would like for the user to be able to enter their number a variety of ways: 999-999-9999, 9-999-9999, (999)999-9999, etc. What's the best way to accomplish this?
My code:
models.py
from django.db import models
from phonenumber_field.modelfields import PhoneNumberField
class Member(models.Model):
"""defines a member for annual registration"""
name = models.CharField(max_length=255)
mailing_address = models.CharField(max_length=255)
home_phone = PhoneNumberField()
other_phone = PhoneNumberField(blank=True)
email = models.EmailField()
forms.py
from django import forms
from .models import Member
class MembershipForm(forms.ModelForm):
"""form for renewing membership"""
class Meta:
model = Member
fields = ('name',
'mailing_address',
'home_phone',
'other_phone',
'email',
)
Thank you for any help!