M2M Examples for docs #172
-
Hi, I'm fairly new to the project and would like to switch the project I am working on entirely to pghistory. Which means being able to track eventhing currently being tracked. I am currently working on getting the m2m fields tracked but cannot seem to find a way to get it to directly ref the main model it belongs to. Is there any way to do this. If so, can an example be added to the docs? P.S. If I figure it out I'll submit a PR to the docs |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
https://django-pghistory.readthedocs.io/en/3.4.4/event_tracking/?h=many#many-to-many-fields discusses how to track M2M fields. A M2M model effectively just has a primary key and two foreign keys to the relationships. If you check out the example in the docs, two trackers have been set up to just track inserts and deletes to this table, allowing you to preserve a history of when M2M relationships are added and deleted. |
Beta Was this translation helpful? Give feedback.
-
You can. I probably was trying to do more than the intended use. I'll work
on it.
…On Tue, 22 Oct 2024, 10:20 Wes Kendall, ***@***.***> wrote:
Closed #172 <#172>
as resolved.
—
Reply to this email directly, view it on GitHub
<#172>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFFXNR5DLAACHMEUWLFBR3Z4ZNLRAVCNFSM6AAAAABP5CXQQ6VHI2DSMVQWIX3LMV45UABFIRUXGY3VONZWS33OIV3GK3TUHI5E433UNFTGSY3BORUW63R3GE2TMNRXGI3Q>
.
You are receiving this because you authored the thread.Message ID:
<Opus10/django-pghistory/repo-discussions/172/discussion_event/1566727@
github.com>
|
Beta Was this translation helpful? Give feedback.
https://django-pghistory.readthedocs.io/en/3.4.4/event_tracking/?h=many#many-to-many-fields discusses how to track M2M fields.
A M2M model effectively just has a primary key and two foreign keys to the relationships. If you check out the example in the docs, two trackers have been set up to just track inserts and deletes to this table, allowing you to preserve a history of when M2M relationships are added and deleted.