In django.db.models.fields.related.SingleRelatedObjectDescriptor?, The
code for __get__:

    def __get__(self, instance, instance_type=None):
        if instance is None:
            raise AttributeError, "%s must be accessed via instance" %
self.related.opts.object_name
        params = {'%s__pk' % self.related.field.name:
instance._get_pk_val()}
        rel_obj = self.related.model._default_manager.get(**params)
        return rel_obj

Here, if "instance._get_pk_val()" returns None, then the get(**params)
will return *any* object.

(The primary key could be None for a new, unsaved object, for
instance.)

More sensible would either to be to return None or raise
self.related.model.DoesNotExist?.

PS I submitted this to the bug tracker, and was told that the my
submission was spam! Very Annoying! Obviously, code in the submission
should be prefiltered before sending off to a general-purpose spam
filter. A prevalence of keywords related to django should be counted as
a plus. You are probably loosing real bugs by this. (Maybe check if I'm
human, if you must.)


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

Reply via email to