On May 19, 1:29 pm, bcurtu <[EMAIL PROTECTED]> wrote:
> Thanks Rajesh,
>
> The actual question is what the difference is between those 2
> definitions, between a OntToOne and an instance relationship?

A OneToOneField in a model class implies that Django will create a
database-level Foreign Key (with a unique=True constraint) that maps
that field (ins) to the parent object's (i.e. Instrument's) database
table. Django will create this when you run syncdb.

Furthermore, Django's object relational mapping (ORM) will allow you
to access an instance of Instrument from the Other2 table and vice-
versa.

On the other hand, a plain Python instance on the Other class will not
connect Instrument to Other at the database level. All you will get is
that Other.ins will point to an instance of the class Instrument. When
you save Other to the database, the field 'ins' will not be saved
because it is not an instance of models.*Field.

In other words, the class models.OneToOneField is a special Django
class which through the Django ORM machinery mimics a database key.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to