Opened 18 years ago
Closed 17 years ago
#2307 closed defect (wontfix)
[patch] Some shortcomings of the PhoneNumberField
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Validators | Version: | |
Severity: | trivial | Keywords: | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The PhoneNumberField type is not terribly useful as shipped:
- It really should be called USPhoneNumberField since it won't accept international numbers, and outside of the US where numbers are 10 digits long they don't necessarily group them 3+3+4
- The underlying database field stores 20 characters, but the admin web interface only lets me type in 12 (which admittedly is all the validator will currently accept anyhow)
- The validator only accepts numbers in the exact form xxx-xxx-xxxx whereas other formats and separators are as common or more so in general use: (nnn) nnn-nnnn or 1-800-BISNESS are the main examples that come to mind.
I can't fix the first problem -- creating code that will recognize all national phone number formats is not really feasible, and I'm assuming that renaming the field type is also probably not possible at this stage. However I do have a short patch I will attach to this ticket that fixes the other two issues:
- Increases the length and maxlength of the form fields to the size of the underlying database
- Permit additional number formats to be entered such as the ones shown above.
Hope it's useful,
- Andrew
Attachments (3)
Change History (8)
by , 18 years ago
Attachment: | phone.patch added |
---|
comment:1 by , 18 years ago
Summary: | Some shortcomings of the PhoneNumberField → [patch] Some shortcomings of the PhoneNumberField |
---|
Omitted [patch] from the ticket title...
comment:2 by , 18 years ago
I agree. phone_re should be something like this to check for international numbers.
phone_re = re.compile(r'\d?\d?\d?-?[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE)
comment:3 by , 18 years ago
I agree. However in europe we often use formats like +46 12 34 56 78 so please take this into account.
by , 18 years ago
Regular expression for national telephone numbers. Put it in .../django/core/
comment:4 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:5 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
The contrib.localflavor app is designed to handle this sort of issue.
Patch to fix the shortcomings discussed in ticket.