Ticket #9885: query.diff
File query.diff, 1.6 KB (added by , 16 years ago) |
---|
-
django/db/models/query.py
379 379 """ 380 380 Deletes the records in the current QuerySet. 381 381 """ 382 from django.db.models import signals 383 382 384 assert self.query.can_filter(), \ 383 385 "Cannot use 'limit' or 'offset' with delete." 384 386 387 signals.pre_batch_delete.send(sender=self.model, queryset=self) 385 388 del_query = self._clone() 386 389 387 390 # Disable non-supported fields. … … 403 406 404 407 # Clear the result cache, in case this QuerySet gets reused. 405 408 self._result_cache = None 409 signals.post_batch_delete.send(sender=self.model, queryset=self) 410 406 411 delete.alters_data = True 407 412 408 413 def update(self, **kwargs): … … 410 415 Updates all elements in the current QuerySet, setting all the given 411 416 fields to the appropriate values. 412 417 """ 418 from django.db.models import signals 419 413 420 assert self.query.can_filter(), \ 414 421 "Cannot update a query once a slice has been taken." 422 signals.pre_batch_update.send(sender=self.model, queryset=self, raw=kwargs) 415 423 query = self.query.clone(sql.UpdateQuery) 416 424 query.add_update_values(kwargs) 417 425 rows = query.execute_sql(None) 426 signals.post_batch_update.send(sender=self.model, queryset=self, raw=kwargs) 418 427 transaction.commit_unless_managed() 419 428 self._result_cache = None 420 429 return rows