Skip to content

Conversation

sk-
Copy link
Contributor

@sk- sk- commented Sep 23, 2025

Django allow to query decimal fields with int, and given there should be no precision loss, we should accept ints to query such fields.

Note: even though we do accept floats when setting a value in a decimal field, I opted for only accepting ints in this PR, as to minimize the impact of the change.

Related issues

Closes #2831

Django allow to query decimal fields with int, and given there should be no precision loss, we should accept ints to query such fields.

Note: even though we do accept floats when setting a value in a decimal field, I opted for only accepting ints in this PR, as to minimize the impact of the change.

Fixes typeddjango#2831.
@UnknownPlatypus
Copy link
Contributor

Hey, thanks for the PR! Could you add a small regression test next to this test showcasing correct filter values and ones that should raise error?

- case: filter_with_invalid_type

@sk-
Copy link
Contributor Author

sk- commented Sep 24, 2025

Hey, thanks for the PR! Could you add a small regression test next to this test showcasing correct filter values and ones that should raise error?

- case: filter_with_invalid_type

Thanks @UnknownPlatypus, I had written the test but forgot to add it to the PR. Let me know if the test I added is enough.

@sobolevn sobolevn merged commit dc2a00c into typeddjango:master Sep 24, 2025
39 checks passed
@UnknownPlatypus
Copy link
Contributor

Thanks @UnknownPlatypus, I had written the test but forgot to add it to the PR. Let me know if the test I added is enough.

Awesome, thanks @sk-

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

Successfully merging this pull request may close these issues.

DecimalField should accept ints
3 participants