Ticket #4260: mult_update.diff
File mult_update.diff, 1.0 KB (added by , 17 years ago) |
---|
-
db/models/query.py
379 379 "Returns a new QuerySet instance with the args ANDed to the existing set." 380 380 return self._filter_or_exclude(None, *args, **kwargs) 381 381 382 def update(self, *args, **kwargs): 383 "Updates records in queryset" 384 assert len(kwargs), 'update() must be passed at least one keyword argument' 385 for obj in self: 386 for k, v in kwargs.items(): 387 if '__' not in k: 388 assert k in [f.column for f in obj._meta.fields], 'update() should contain a valid field name, %s Does not exist.' % k 389 setattr(obj, k, v) 390 obj.save() 391 return self 392 393 382 394 def exclude(self, *args, **kwargs): 383 395 "Returns a new QuerySet instance with NOT (args) ANDed to the existing set." 384 396 return self._filter_or_exclude(QNot, *args, **kwargs)