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

FieldInstanceTracker.changed should support exclusion lists #527

Open
lociii opened this issue May 24, 2022 · 0 comments
Open

FieldInstanceTracker.changed should support exclusion lists #527

lociii opened this issue May 24, 2022 · 0 comments

Comments

@lociii
Copy link

lociii commented May 24, 2022

Problem

I'm using a custom base model quite often that automatically sets a certain field in it's overridden save method. Using FieldTracker().changed() will then obviously return this field as changed.
To make my life easier excluding such an automatic change, I'd like to introduce exclude lists to FieldInstanceTracker.changed.

Signature would change from

def changed(self):

to

def changed(self, exclude: list = None) -> dict:

so that it will be fully backwards compatible.
exclude should be a list of field names that will be omitted when generating the result dict.

If you think that this will be a suitable addition to the library, then I'd be happy to provide a pull request.
Just one open question: Would you like the tests to be synthetic one just for FieldInstanceTracker.changed or extend FieldTrackerTests etc. accordingly with a assertChangedExcludes test every time an assertChanged test happens right now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant