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

Add ignore_empty Parameter to has_changed Method #621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mng-dev-ai
Copy link

Problem

The has_changed method returns True if the value changes from null to "" and vice versa, which is often not what we want

Solution

Added ignore_empty parameter with default value to True to ignore if value changed from null to "" and vice versa

Tests

I will add tests if you agree on the idea of this pr

@Mng-dev-ai Mng-dev-ai force-pushed the ignore-empty-value-when-field-changes branch from dff2f18 to 73d3395 Compare May 26, 2024 13:30
@foarsitter
Copy link
Contributor

Can you describe a use-case where None to empty string shouldn't be an actual change?

To me this sounds a little as https://docs.astral.sh/ruff/rules/django-nullable-model-string-field/

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

Successfully merging this pull request may close these issues.

2 participants