@@ -456,7 +456,7 @@ If you want to track many to many relationships, you need to define them explici
456456.. code-block :: python
457457
458458 class Category (models .Model ):
459- pass
459+ name = models.CharField( max_length = 200 )
460460
461461 class Poll (models .Model ):
462462 question = models.CharField(max_length = 200 )
@@ -474,19 +474,19 @@ You will see the many to many changes when diffing between two historical record
474474
475475.. code-block :: python
476476
477- informal = Category(name = " informal questions" )
478- official = Category(name = " official questions" )
477+ informal = Category.objects.create (name = " informal questions" )
478+ official = Category.objects.create (name = " official questions" )
479479 p = Poll.objects.create(question = " what's up?" )
480480 p.save()
481481 p.categories.add(informal, official)
482482 p.categories.remove(informal)
483483
484484 last_record = p.history.latest()
485- previous_record = last_record.prev_record()
485+ previous_record = last_record.prev_record
486486 delta = last_record.diff_against(previous_record)
487487
488488 for change in delta.changes:
489- print (" {} changed from {} to {} " )
489+ print (" {} changed from {} to {} " .format(change.field, change.old, change.new) )
490490
491491 # Output:
492492 # categories changed from [{'poll': 1, 'category': 1}, { 'poll': 1, 'category': 2}] to [{'poll': 1, 'category': 2}]
0 commit comments