Ticket #3849: onetoonefield-edit_inline-related.patch

File onetoonefield-edit_inline-related.patch, 847 bytes (added by simon@…, 18 years ago)

this additional patch seems to be required too

  • django/db/models/fields/related.py

     
    126126            raise AttributeError, "%s must be accessed via instance" % self.related.opts.object_name
    127127
    128128        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
    131135
    132136    def __set__(self, instance, value):
    133137        if instance is None:
Back to Top