On Thu, Jun 16, 2011 at 11:24 AM, Ivo Brodien <[email protected]> wrote:
>
> Actually, I've read that ForeignKey is now the way to specify it.
>
> unique foreign key *was* the correct way as onetoone was broken. This is
> no longer true.
>
> where is the most up to date info on this?
> In the dev docs about storing additional user info on djangoproject.com
> there is a link to an old Django Book
> Chapter 12 of the Django book
> there it says:
>

In the paragraph preceding this link it explicitly states to use
OneToOneField. The Django documentation is canonical, if it says one
thing, and elsewhere on the internet says something else, the internet
is wrong. The internet is often wrong.

The difference between a ForeignKey(unique=True) and OneToOneField is
that on the reverse side of the relationship, the one-to-one is
represented as a single attribute on the instance, where as the
foreign key is represented as an object manager.

Eg:

user = User.objects.get(id=1)
user.userprofile_set.get() # If it is a ForeignKEy
user.userprofile # If it is OneToOneField

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users?hl=en.

Reply via email to