Coding for arbitrary additional fields of a certain type

0 views
Skip to first unread message

Daniele Procida

unread,
Jun 27, 2009, 1:55:53 PM6/27/09
to Django Users
I am wondering what sort of coding/storage approach to take to manage
contact details in a more sophisticated way.

For example, one person might need:

Phone (London): xxx xxxxx
Phone (Edinburgh): xxx xxxxxx

and another:

Phone (office): xxx xxxx
Phone (laboratory): xxx xxxx
Phone (mobile): xxx xxxxx

but you can't know in advance how any particular person might need their
details labelled.

Is there a name for this kind of scheme, or a standard way of handling it?

Thanks,

Daniele

Alex Gaynor

unread,
Jun 27, 2009, 2:07:54 PM6/27/09
to django...@googlegroups.com
Yep, you'd have a second model that has a foreign key to person that has the type and number fields on it.

Alex

--
"I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire
"The people's good is the highest law."--Cicero

lzantal

unread,
Jun 27, 2009, 3:56:21 PM6/27/09
to django...@googlegroups.com, Django Users
Hi,

On Jun 27, 2009, at 10:55 AM, "Daniele Procida" <dan...@apple-juice.co.uk
I had a similar need a few months ago.
What I did is I stored those info in a database in ini format.
So after running the query I parsed it as an ini conf data. It works
great.

Hope that helps

Laszlo Antal
http://www.antalconsulting.com
http://twitter.com/lzantal
Office: 208-699-7508
>
> >

James

unread,
Jun 28, 2009, 6:51:28 AM6/28/09
to Django users

On Jun 27, 8:56 pm, lzantal <lzan...@gmail.com> wrote:
> Hi,
>
> On Jun 27, 2009, at 10:55 AM, "Daniele Procida" <dani...@apple-juice.co.uk
>
>
>
>  > wrote:
>
> > I am wondering what sort of coding/storage approach to take to manage
> > contact details in a more sophisticated way.
>
> > For example, one person might need:
>
> > Phone (London): xxx xxxxx
> > Phone (Edinburgh): xxx  xxxxxx
>
> > and another:
>
> > Phone (office): xxx xxxx
> > Phone (laboratory): xxx xxxx
> > Phone (mobile): xxx xxxxx
>
> > but you can't know in advance how any particular person might need  
> > their
> > details labelled.
>
> > Is there a name for this kind of scheme, or a standard way of  
> > handling it?
>
> > Thanks,
>
> > Daniele
>
> I had a similar need a few months ago.
> What I did is I stored those info in a database in ini format.
> So after running the query I parsed it as an ini conf data. It works  
> great.
>

Doesn't that make searching by number a nightmare? I'd favour Alex's
approach myself.

Reply all
Reply to author
Forward
0 new messages