I think the easiest way of understanding the behaviour is that
specifying a field like this:

   owner = models.ForeignKey(Owner)

specifies a contract. The contract says that when you access this
attribute on an instance, it will only return an instance of an Owner
object or raise an DoesNotExist exception.

Specifying a field like this:

  owner = models.ForeignKey(Owner,blank=True,null=True)

specifies a very different contract. This contract says that accessing
this attribute will return either an instance of an Owner object, or
None if no owner has been specified.

Both contracts are fully described in the documentation and fulfilled
by the ORM, so clearly this is no bug. Both flavours are available for
you to use, you simply have to decide what sort of contract you want
that attribute to have - if you expect instance.owner to return None,
then clearly you should be using a nullable foreign key.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to