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 unknown_field_behavior feature #1675

Merged
merged 4 commits into from
Jul 19, 2024

Conversation

loeeess
Copy link
Contributor

@loeeess loeeess commented Jul 10, 2024

Based on the suggestion mentioned in #1666, I have added the handle_unrecognized_field method to the BaseFilterSet and a new option unknown_field_behavior in FilterSetOptions where users can specify how unrecognized field types should be handled (raise - default, warn, ignore).

Changes include:

  • Implementation of handle_unrecognized_field method in BaseFilterSet, including new FilterSet option
  • Add tests for raise, warn, ignore, and invalid behaviors

Copy link
Owner

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

Next steps would be to add the option to the Filterset reference doc.

tests/test_filterset.py Outdated Show resolved Hide resolved
django_filters/filterset.py Show resolved Hide resolved
Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  django_filters
  __init__.py
  filterset.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link
Owner

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking nice and tight. 👍

@loeeess
Copy link
Contributor Author

loeeess commented Jul 12, 2024

Just added a change to the docs. Not sure if the following line is redundant due to the explanation for each enum value:

Note that both the WARN and IGNORE options do not include the unknown field(s) in the list of filters.

Copy link
Owner

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this looks great. Let's have it! Welcome aboard! ⛵️

I will look towards a release.

@carltongibson carltongibson merged commit 376d443 into carltongibson:main Jul 19, 2024
9 checks passed
@carltongibson
Copy link
Owner

This is now available in v24.3 on PyPI. Thanks @loeeess!

@loeeess
Copy link
Contributor Author

loeeess commented Aug 10, 2024

That's great to see @carltongibson , thanks so much! 🎉

What's the best way to proceed, should I close the issue?

@carltongibson
Copy link
Owner

Oops. I didn't see that. Closed it now. Thanks.

last-partizan pushed a commit to last-partizan/django-filter that referenced this pull request Sep 12, 2024
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