Ticket #3188: patch.diff
File patch.diff, 2.2 KB (added by , 18 years ago) |
---|
-
django/db/models/manipulators.py
160 160 # old to the new, to see which fields have changed. 161 161 old_rel_obj = None 162 162 if self.change: 163 if rel_new_data[related.opts.pk.name][0]: 164 try: 165 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]}) 166 except ObjectDoesNotExist: 167 pass 163 from django.db.models.fields.related import OneToOneField 164 if type(related.field)==OneToOneField: 165 old_rel_obj = getattr(self.original_object, related.get_accessor_name()) 166 else: 167 if rel_new_data[related.opts.pk.name][0]: 168 try: 169 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]}) 170 except ObjectDoesNotExist: 171 pass 168 172 169 173 for f in related.opts.fields: 170 174 if f.core and not isinstance(f, FileField) and f.get_manipulator_new_data(rel_new_data, rel=True) in (None, ''): … … 203 207 if isinstance(f, FileField) and rel_new_data.get(f.name, False): 204 208 f.save_file(rel_new_data, new_rel_obj, self.change and old_rel_obj or None, old_rel_obj is not None, rel=True) 205 209 206 # Calculate whether any fields have changed.207 210 if self.change: 208 211 if not old_rel_obj: # This object didn't exist before. 209 212 self.fields_added.append('%s "%s"' % (related.opts.verbose_name, new_rel_obj))