Ticket #4102: 4102_django-1.1.patch
| File 4102_django-1.1.patch, 2.0 kB (added by seandong, 9 months ago) |
|---|
-
django/db/models/base.py
old new 240 240 class Model(object): 241 241 __metaclass__ = ModelBase 242 242 _deferred = False 243 244 def __setattr__(self, name, value): 245 if name not in self._modified_attrs: 246 if not hasattr(self, name) or value != getattr(self, name): 247 self._modified_attrs.append(name) 248 super(Model, self).__setattr__(name, value) 249 250 def _reset_modified_attrs(self): 251 self.__dict__['_modified_attrs'] = [] 243 252 244 253 def __init__(self, *args, **kwargs): 254 self._reset_modified_attrs() 245 255 signals.pre_init.send(sender=self.__class__, args=args, kwargs=kwargs) 246 256 247 257 # There is a rather weird disparity here; if kwargs, it's set, then args … … 458 468 459 469 if not meta.proxy: 460 470 non_pks = [f for f in meta.local_fields if not f.primary_key] 461 471 modified_attrs = self._modified_attrs 472 non_pks = [f for f in non_pks if (f.name in modified_attrs or f.attname in modified_attrs)] 473 self._reset_modified_attrs() 474 462 475 # First, try an UPDATE. If that doesn't update anything, do an INSERT. 463 476 pk_val = self._get_pk_val(meta) 464 477 pk_set = pk_val is not None
