Pass Field Name to Compare Function
Opened this issue · 1 comments
Is your feature request related to a problem? Please describe.
I have a decimal field that is limited to 4 decimal places. Even if the persisted value will end up the same, the field will be marked as dirty if the extra decimal places make it different than the current value. I'm trying to write a custom compare function to round the decimal before comparing it, but I haven't been able to find a way to tell which field is being compared.
Describe the solution you'd like
I'd like to pass the field name along with the old and new value to the compare function. That would allow me to check the number of decimal places in that field and accurately check if the decimals will end up equal.
Describe alternatives you've considered
I've considered calling full_clean
first, but since that hasn't historically been done in my codebase, it could cause issues. I've also tried writing a custom compare_function, but can't find a way to tell which field I'm comparing so I can check how many decimal places it should compare to.
This sounds like a sensible feature to me, I'll try to implement this in a future version.
If you need this right now I recommend you fork and modify compare.compare_states()
since I can't see any other good way to achieve this.