Skip to content

Commit 800bf33

Browse files
committed
Add option to exclude fields in History.
1 parent 6580dde commit 800bf33

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

simple_history/models.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ class HistoricalRecords(object):
3636
thread = threading.local()
3737

3838
def __init__(self, verbose_name=None, bases=(models.Model,),
39-
user_related_name='+', table_name=None, inherit=False):
39+
user_related_name='+', table_name=None, inherit=False,
40+
excluded_fields=[]):
4041
self.user_set_verbose_name = verbose_name
4142
self.user_related_name = user_related_name
4243
self.table_name = table_name
4344
self.inherit = inherit
45+
self.excluded_fields = excluded_fields
4446
try:
4547
if isinstance(bases, six.string_types):
4648
raise TypeError
@@ -138,7 +140,8 @@ def copy_fields(self, model):
138140
a dictionary mapping field name to copied field object.
139141
"""
140142
fields = {}
141-
for field in model._meta.fields:
143+
fields_to_copy = set(model._meta.fields) - set(self.excluded_fields)
144+
for field in fields_to_copy:
142145
field = copy.copy(field)
143146
try:
144147
field.remote_field = copy.copy(field.remote_field)

0 commit comments

Comments
 (0)