Many to many only with explicit through models? #224
-
Regarding the tracking of many-to-many relationships: I gather from the documentation (https://django-pghistory.readthedocs.io/en/3.8.0/event_tracking/#many-to-many-fields) that the through model has to be declared explicitly for pghistory to track these. Just having a ManyToManyField in a model won't be enough. Am I right? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The through model does not have to be declared explicitly, but the tracking model does. Here is the example from the docs you linked, but with the models declared:
In other words, we don't have to declare an explicit through model on Hope this distinction makes sense. I was unable to support |
Beta Was this translation helpful? Give feedback.
-
Thanks for the clarification - works! |
Beta Was this translation helpful? Give feedback.
The through model does not have to be declared explicitly, but the tracking model does.
Here is the example from the docs you linked, but with the models declared:
In other words, we don't have to declare an explicit through model on
groups
like this example in the Django docs. However, in order for pghistory to track the auto-generated M2M model, one must declare a tracker on a proxy model …