Ticket #3519: ticket3519.diff

File ticket3519.diff, 1.4 KB (added by wiz, 18 years ago)

workaround

  • django/db/models/manipulators.py

     
    160160                    # old to the new, to see which fields have changed.
    161161                    old_rel_obj = None
    162162                    if self.change:
    163                         if rel_new_data[related.opts.pk.name][0]:
     163                        if rel_new_data[related.opts.pk.name] and rel_new_data[related.opts.pk.name][0]:
    164164                            try:
    165165                                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]})
    166166                            except ObjectDoesNotExist:
  • django/db/models/fields/__init__.py

     
    284284        Given the full new_data dictionary (from the manipulator), returns this
    285285        field's data.
    286286        """
    287         if rel:
     287        if rel and new_data.get(self.name, [self.get_default()]):
    288288            return new_data.get(self.name, [self.get_default()])[0]
    289289        val = new_data.get(self.name, self.get_default())
    290290        if not self.empty_strings_allowed and val == '' and self.null:
Back to Top