Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tuple for m2m_models #1438

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Authors
- Marcelo Canina (`marcanuy <https://github.com/marcanuy>`_)
- Marco Sirabella
- Mark Davidoff
- Marti Markov (`martimarkov <https://github.com/martimarkov>`_)
- Martin Bachwerk
- Marty Alchin
- Matheus Cansian (`mscansian <https://github.com/mscansian>`_)
Expand Down
4 changes: 2 additions & 2 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def finalize(self, sender, **kwargs):
m2m_model = self.create_history_m2m_model(
history_model, field.remote_field.through
)
self.m2m_models[field] = m2m_model
self.m2m_models[(sender._meta.object_name, field)] = m2m_model

setattr(module, m2m_model.__name__, m2m_model)

Expand Down Expand Up @@ -706,7 +706,7 @@ def m2m_changed(self, instance, action, attr, pk_set, reverse, **_):

def create_historical_record_m2ms(self, history_instance, instance):
for field in history_instance._history_m2m_fields:
m2m_history_model = self.m2m_models[field]
m2m_history_model = self.m2m_models[(instance._meta.object_name, field)]
original_instance = history_instance.instance
through_model = getattr(original_instance, field.name).through
through_model_field_names = [f.name for f in through_model._meta.fields]
Expand Down