Ticket #3849: onetoonefield-edit_inline.patch

File onetoonefield-edit_inline.patch, 999 bytes (added by Ilya Semenov <semenov@…>, 18 years ago)
  • django/db/models/manipulators.py

     
    162162                    # old to the new, to see which fields have changed.
    163163                    old_rel_obj = None
    164164                    if self.change:
    165                         if rel_new_data[related.opts.pk.name][0]:
     165                        from django.db.models.fields.related import OneToOneField
     166                        if isinstance(related.opts.pk,OneToOneField):
     167                            old_rel_obj = getattr(self.original_object, related.get_accessor_name())
     168                        elif rel_new_data[related.opts.pk.name][0]:
    166169                            try:
    167170                                old_rel_obj = getattr(self.original_object, related.get_accessor_name()).get(**{'%s__exact' % related.opts.pk.name: rel_new_data[related.opts.pk.attname][0]})
    168171                            except ObjectDoesNotExist:
Back to Top