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
Attempting to save a Course object results in this error:
File "C:\data\django\wrds\venv\Lib\site-packages\simple_history\models.py", line 639, in post_save
self.create_historical_record(instance, created and "+" or "~", using=using)
File "C:\data\django\wrds\venv\Lib\site-packages\simple_history\models.py", line 739, in create_historical_record
self.create_historical_record_m2ms(history_instance, instance)
File "C:\data\django\wrds\venv\Lib\site-packages\simple_history\models.py", line 685, in create_historical_record_m2ms
insert_rows.append(m2m_history_model(**insert_row))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\data\django\wrds\venv\Lib\site-packages\django\db\models\base.py", line 565, in __init__
raise TypeError(
TypeError: HistoricalInstructor() got unexpected keyword arguments: 'created_on'
Expected behavior
Save to proceed without error.
Screenshots
Debugging:
...where
The line where the error will occur
Inspecting the contents of the row to be inserted - notice the presence of created_on
The fields of the m2m_history_model - notice that created_on is missing
The contents of self.excluded_field_kwargs
Error: Environment (please complete the following information):
OS: [e.g. Ubuntu 18.04]
Browser (if applicable): [e.g. chrome, safari]
Django Simple History Version: [e.g. 1.9.1]
Django Version: [e.g. 1.11.11]
Database Version: [e.g. PostgreSQL 10.5.0]
Additional context
PR incoming :)
The text was updated successfully, but these errors were encountered:
Describe the bug
TypeErrors are thrown when saving a model having m2m_fields with excluded fields.
This is simply resolved by conditioning the casll to
insert_row[field_name] = getattr(row, field_name)
with:To Reproduce
Given an m2m setup like
Attempting to save a Course object results in this error:
Expected behavior
Save to proceed without error.
Screenshots
Debugging:
...where
created_on
m2m_history_model
- notice thatcreated_on
is missingself.excluded_field_kwargs
Error:
Environment (please complete the following information):
Additional context
PR incoming :)
The text was updated successfully, but these errors were encountered: