Ticket #3873: django.diff
File django.diff, 2.0 KB (added by , 18 years ago) |
---|
-
django/db/models/manipulators.py
162 162 # old to the new, to see which fields have changed. 163 163 old_rel_obj = None 164 164 if self.change: 165 if rel_new_data[related.opts.pk.name] [0]:165 if rel_new_data[related.opts.pk.name]: 166 166 try: 167 167 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]}) 168 168 except ObjectDoesNotExist: … … 242 242 243 243 def flatten_data(self): 244 244 new_data = {} 245 obj = self.change and self.original_object or None 245 if self.change: 246 obj = self.original_object 247 else: 248 obj = None 246 249 for f in self.opts.get_data_holders(self.follow): 247 250 fol = self.follow.get(f.name) 248 251 new_data.update(f.flatten_data(fol, obj)) -
django/db/models/fields/__init__.py
286 286 field's data. 287 287 """ 288 288 if rel: 289 return new_data.get(self.name, [self.get_default()]) [0]289 return new_data.get(self.name, [self.get_default()]) 290 290 val = new_data.get(self.name, self.get_default()) 291 291 if not self.empty_strings_allowed and val == '' and self.null: 292 292 val = None … … 311 311 return self.get_choices() 312 312 313 313 def _get_val_from_obj(self, obj): 314 if obj :314 if obj is not None: 315 315 return getattr(obj, self.attname) 316 316 else: 317 317 return self.get_default()