> > <nikhil.kodil...@gmail.com> wrote:
>
> > > Thanks Karen.
> > > Let me explain it a bit more.
> > > e.g.
> > > All CONTACT details are present in one table - email, home address,
> > > work address, home phone, work phone etc.
> > > Forget about the statement about growing for now.
> > > Since each user "has-a" contact it is a pure one-to-one relationship
> > > and not a one-to-many or many-to-one; each user in the USER table will
> > > have only one corresponding entry in the CONTACT table.
> > > Does this help explaining the issue ?
> > > The above is just an example, the main question is how does one
> > > usually implement a "has-a" relationship in dJango.
>

There are a few things being overlooked here:

1. This cookie has been baked before.  Instead of talking about it in
the abstract, check out django-profiles or django-basic-apps (and
there are more I'm sure).  That app will give you much better control
over contact details for a user in a robust way.  Just use that app
and you can focus on import things like what your project does:

http://bitbucket.org/ubernostrum/django-profiles/wiki/Home
http://code.google.com/p/django-basic-apps/source/browse/#svn/trunk/profiles

2.  There are two ways to handle the issue generally - A symmetrical
one-to-one key allowing any profile to get its user or vice versa, and
extending the User class with something like:

class Profile(User):
    email = models....
    phone = models....

@PlanetUnkown - you haven't really stated what's wrong with extending
the user like that, nor what is wrong with the one-to-one, so nobody
can help you any more than to tell you either one of those will do
what you want it to do.  I personally would extend the User model for
your limited need but most profile apps use a ForeignKey field
(OneToMany) so as to support multiple profiles per user.

Cheers,
Adam
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to