I'm using Flask-Admin 2.1 with Python 2.7.6.
One of my Flask-Admin model classes inherits from flask.ext.admin.contrib.sqla.ModelView and overrides form_rules
.
When I run my application, this warning is displayed: "UserWarning: Fields missing from ruleset"
The warning is accurate: There are fields in my model that are not included in the ruleset. But that's by design. I don't want those fields to be displayed when users create or edit instances of this model.
I have already read this: https://github.com/flask-admin/flask-admin/pull/815#issuecomment-81963865
How can I suppress the warning?
You can suppress the warning when the view is added by using this snippet with the assumed name UserView:
import warnings
with warnings.catch_warnings():
warnings.filterwarnings('ignore', 'Fields missing from ruleset', UserWarning)
admin.add_view(UserView())
Reference: https://docs.python.org/2/library/warnings.html#warnings.filterwarnings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With