Skip to content
Discussion options

You must be logged in to vote

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:

class Group(models.Model):
    ...

class User(models.Model):
    groups = models.ManyToMany(Group)


@pghistory.track(
    pghistory.AfterInsert("group.add"),
    pghistory.BeforeDelete("group.remove"),
    obj_field=None,
)
class UserGroups(User.groups.through):
    class Meta:
        proxy = True

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 …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by stephan0h
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants