Skip to content

Commit 309609e

Browse files
authored
docs - fix code example (historical_model) (#1069)
1 parent 864bda7 commit 309609e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/common_issues.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Using custom OneToOneFields
260260
---------------------------
261261

262262
If you are using a custom OneToOneField that has additional arguments and receiving
263-
the the following ``TypeError``::
263+
the following ``TypeError``::
264264

265265
TypeError: __init__() got an unexpected keyword argument
266266

docs/historical_model.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)