extras: Improve Django filter for Rut
#878
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



This pull request refactors how substring lookups are handled for Chilean RUT fields in Django filters, centralizing logic in the
RutFilterclass and improving test coverage.The main change is that the selection of the form field class for substring lookups (like
containsandicontains) is now handled withinRutFilter.__init__(), instead of being managed by a customfilter_for_lookup()override inSiiFilterSet. This results in cleaner code and more reliable behavior.Key changes include:
field_classfor substring lookups (contains,icontains) fromSiiFilterSet.filter_for_lookup()into theRutFilterconstructor, ensuring that substring lookups use a plainCharFieldinstead of a strictRutFieldthat would fail on invalid substrings.RutFilterto verify that the correctfield_classis chosen for each lookup expression, and forSiiFilterSetto ensurefilter_for_lookup()returns filters with the correct field classes for different lookup types.