Skip to content

Tracking different fields depending on event #151

Closed Answered by wesleykendall
mustafa0x asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, use multiple invocations of @pghistory.track:

@pghistory.track(
    pghistory.InsetEvent(), pghistory.UpdateEvent(),
    fields=["int_field"],
    model_name="MyTrackedModelInsertUpdateHistory"
)
@pghistory.track(
    pghistory.DeleteEvent(),
    fields=["int_field", "char_field"],
    model_name="MyTrackedModelDeleteHistory"
)
class MyTrackedModel(models.Model):
    int_field = models.IntegerField()
    char_field = models.TextField()

Each invocation of track is associated with a different event model.

A short section for multiple trackers was added in #142

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wesleykendall
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
Converted from issue

This discussion was converted from issue #112 on September 02, 2024 18:53.