@@ -280,31 +280,25 @@ Or you can pass the change reason explicitly:
280
280
poll.save()
281
281
update_change_reason(poll, ' Add a question' )
282
282
283
- Save Without Historical Record
284
- ------------------------------
283
+ Save without a historical record
284
+ --------------------------------
285
285
286
- You want save model without saving a historical record. You can use this method.
286
+ If you want to save a model without a historical record, you can use the following:
287
287
288
288
.. code-block :: python
289
- def save_without_historical_record (self , * args , ** kwargs ):
290
- self .skip_history_when_saving = True
291
- try :
292
- ret = self .save(* args, ** kwargs)
293
- finally :
294
- del self .skip_history_when_saving
295
- return ret
296
-
297
289
298
- .. code-block :: python
299
290
class Poll (models .Model ):
300
291
question = models.CharField(max_length = 200 )
301
292
history = HistoricalRecords()
302
293
303
-
304
- .. code-block :: python
305
- poll = Poll(quetions = ' somthing' )
306
- poll.save_without_historical_record()
307
-
308
-
294
+ def save_without_historical_record (self , * args , ** kwargs ):
295
+ self .skip_history_when_saving = True
296
+ try :
297
+ ret = self .save(* args, ** kwargs)
298
+ finally :
299
+ del self .skip_history_when_saving
300
+ return ret
309
301
310
302
303
+ poll = Poll(question = ' something' )
304
+ poll.save_without_historical_record()
0 commit comments