Ticket #3849: onetoonefield-edit_inline-related.patch
File onetoonefield-edit_inline-related.patch, 847 bytes (added by , 18 years ago) |
---|
-
django/db/models/fields/related.py
126 126 raise AttributeError, "%s must be accessed via instance" % self.related.opts.object_name 127 127 128 128 params = {'%s__pk' % self.related.field.name: instance._get_pk_val()} 129 rel_obj = self.related.model._default_manager.get(**params) 130 return rel_obj 129 try: 130 rel_obj = self.related.model._default_manager.get(**params) 131 return rel_obj 132 except self.related.model.DoesNotExist: 133 rel_obj = self.related.model._default_manager.none() 134 return rel_obj 131 135 132 136 def __set__(self, instance, value): 133 137 if instance is None: