Tuesday, August 9, 2011

Newbie: Help with validation

Hi all,

I have a model snippet that I wanna use to store phonenumbers:

e_mail = models.EmailField()
    phone = models.CharField(max_length=15)

Mobile numbers in my country are 11digit numbers e.g 080xxxxxxxx,
Fixed Lines: (2 digit),7 digit e.g (01)755xxxx

I wanna try and validate this field on a form, ensuring that info supplied is commensurate with above mentioned parameters:

def clean_phone(self):
if self.cleaned_data['phone']  <some validation parameter for all digits> :
raise forms.ValidationError('Phone Number wrong.')
return self.cleaned_data['phone']

Can anyone suggest a validation or regex pattern I can use? If there are other field types I wouldn't mind too; PhoneNumberField(django.contrib.localflavor) doesnt quite cut it for me.

Regards
Damola



From: damola oyeniyi <oyeniyi83@yahoo.ca>
To: "django-users@googlegroups.com" <django-users@googlegroups.com>
Sent: Tuesday, August 9, 2011 2:57:36 PM
Subject: Re: problem with django admin

Hi all,

Anybody know a good documentation or book that can help me with integrating google maps with my app?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate