carltongibson / django-filter

A generic system for filtering Django QuerySets based on user selections
https://django-filter.readthedocs.io/en/main/
Other
4.45k stars 766 forks source link

Add unknown_field_behavior feature #1675

Closed loeeess closed 2 months ago

loeeess commented 3 months ago

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:

github-actions[bot] commented 3 months ago

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

loeeess commented 3 months ago

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.

carltongibson commented 2 months ago

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

loeeess commented 2 months ago

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

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

carltongibson commented 2 months ago

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