On Wed, 2007-06-13 at 09:49 -0400, Waylan Limberg wrote: > On 6/13/07, Tai Lee <[EMAIL PROTECTED]> wrote: > > > > i'd like to see a single generic phone number field, and different > > methods attached to it that format it to the required formats. usa, > > international, including or excluding country code, using spaces or > > dashes, with or without leading zeroes, etc. > > > > This can all be done with a basic CharField in the model and some > custom newforms widgets. Which brings the question, why do we even > need a PhoneNumberField at the db level? Although I suppose it helps > with the admin, form_for_model, etc.
As a general rule, if your data is only coming in via forms, the custom widgets do everything you want. However, if you are also taking data from other places, having normalising convertors and integrity validation checks on the model fields themselves are useful too. That being said, I'm personally not a big fan of adding extra model fields to core. It's always a huge debate about why field X is more useful than field Y and which particular features it should have and soon you end up having to read the instruction manual just to use it. Sure, given a free hand to design things without considering backwards-compat and if it was zero work (which are two reasons why this is only hypothetical), I'd pitch all the US-centric fields from models and put more general things in their place in some cases, but it's not harmful to have the existing ones there either. Making Field sub-classing easier is the solution here, so that people can write whatever customisations suit their particular problem domain. Something like an all-singing, all-dancing telephone number field as Tai wants to use is already possible, I suspect, although it's not really documented how to do it. Other types of fields (particularly those backing onto non-standard database fields -- say CIDR fields in PostgreSQL) are not yet possible. That's work in progress, though. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
