You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem Statement
Coercing OneToOneFields to be ForeignKeys 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'
This is caused by #167 and somewhat related to #462.
The text was updated successfully, but these errors were encountered:
Coercing OneToOneFields to be ForeignKeys on historical
models causes issues when the OneToOneField is a custom
subclass that includes additional arguments that do not
exist on the ForeignKey.__init__ method.
These additional arguments can be specified via excluded_field_kwargs
to allow these custom OneToOneFields be coerced into ForeignKeys
on the historical model.
Fixesjazzband#870
Coercing OneToOneFields to be ForeignKeys on historical
models causes issues when the OneToOneField is a custom
subclass that includes additional arguments that do not
exist on the ForeignKey.__init__ method.
These additional arguments can be specified via excluded_field_kwargs
to allow these custom OneToOneFields be coerced into ForeignKeys
on the historical model.
Fixes#870
Co-authored-by: Jim King <[email protected]>
Problem Statement
Coercing
OneToOneField
s to beForeignKey
s on historical models causes issues when theOneToOneField
is a custom subclass that includes additional arguments that do not exist onForeignKey.__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
, aTypeError
is raised:This is caused by #167 and somewhat related to #462.
The text was updated successfully, but these errors were encountered: