Personally, I would just create a custom Form for that validation logic then store the number in some generic Model Field (like IntegerField). You can write a method in your model to format that integer as a telephone number for display purposes using __string__ or other similar methods. Just convert to a unicode object and go right-to-left, adding hyphenation, parenthesis, etc... as needed. Also, check out the Model Fields LocalFlavor stuff, there *may* be a telephone number field already? I know there are address fields. I'd look for you, but I got to get back to work :/ Good luck!
https://docs.djangoproject.com/en/1.3/ref/contrib/localflavor/ On Mon, Mar 19, 2012 at 9:41 AM, BGMaster <bsbech...@gmail.com> wrote: > That looks like it could work. The problem I'm having is tying into a > ModelForm. I want to create something basically to the effect of: > > phoneNumber = phoneNumber1+phoneNumber2 > > Here, phoneNumber1 and phoneNumber2 are the first 3 and last 4 digits > of a user's phone number. I want them input as separate fields for > sake of readability and then want to combine them into one model for > searchability in the database. Do you have an example of > MultiValueField? The django documentation isn't very clear on it. > Here's what I've been trying: > > class launchForm(ModelForm): > phoneNumber = forms.MultiValueField(fields=[phoneNumber1(), > phoneNumber2()]) > > class Meta: > model = potentialUser > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.