Skip to content

Commit bd5667c

Browse files
committed
Add fields_included when return object
1 parent 928354d commit bd5667c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

simple_history/models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def get_instance(self):
217217
('~', 'Changed'),
218218
('-', 'Deleted'),
219219
)),
220-
'history_object': HistoricalObjectDescriptor(model),
220+
'history_object': HistoricalObjectDescriptor(model, self.fields_included(model)),
221221
'instance': property(get_instance),
222222
'instance_type': model,
223223
'revert_url': revert_url,
@@ -311,10 +311,11 @@ def convert_auto_field(field):
311311

312312

313313
class HistoricalObjectDescriptor(object):
314-
def __init__(self, model):
314+
def __init__(self, model, fields_included):
315315
self.model = model
316+
self.fields_included = fields_included
316317

317318
def __get__(self, instance, owner):
318319
values = (getattr(instance, f.attname)
319-
for f in self.model._meta.fields)
320+
for f in self.fields_included)
320321
return self.model(*values)

0 commit comments

Comments
 (0)