Closed
Description
Problem Statement
Coercing OneToOneField
s to be ForeignKey
s on historical models causes issues when the OneToOneField
is a custom subclass that includes additional arguments that do not exist on ForeignKey.__init__
.
Describe the solution you'd like
In my particular case, ignoring the value would work well. My proposed solution is to supply a dictionary to HistoricalRecords
that maps fields to the list of kwargs that should be excluded.
Describe alternatives you've considered
I did not consider alternatives.
Additional context
Currently when trying to use a custom OneToOneField
, a TypeError
is raised:
File "python3.9/site-packages/simple_history/models.py", line 159, in finalize
history_model = self.create_history_model(sender, inherited)
File "python3.9/site-packages/simple_history/models.py", line 221, in create_history_model
fields = self.copy_fields(model)
File "python3.9/site-packages/simple_history/models.py", line 302, in copy_fields
field = FieldType(*args, **field_args)
File "python3.9/site-packages/django/db/models/fields/related.py", line 825, in __init__
super().__init__(
File "python3.9/site-packages/django/db/models/fields/related.py", line 474, in __init__
super().__init__(rel=rel, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'custom_field'
Metadata
Metadata
Assignees
Labels
No labels