Search code examples
pythonfilterflaskadminflask-admin

Flask-Admin: Default List Filters don't work


I'm coding on Python for Web using microframework Flask. All is simple and perfect but now I have a silly problem that can't resolve for 3 days. I have a model list via Flask-Admin with Flask-Admin default search and filters. Search is fine but filters driving me crazy. I add a default filter to the View model class in my code:

class OkndView(ModelsView):
     column_filters = ('kind',)

So now I have an option in the view to Add Filter. When I click on it a dropdown appears with my 'kind' field. Next when I clicked on this item nothing heppen. No filter appears. I checked an example on http://examples.flask-admin.org/sqla/simple/admin/postview/. In HTML code of this page I found a container:

<form id="filter_form" method="GET" action="/sqla/simple/admin/postview/">
    <div class="pull-right">
        <button type="submit" class="btn btn-primary" style="">Apply</button>

    </div>

    <table class="filters">
    <tbody></tbody></table>
</form>

I have no such a container and also nothing about filters in my generated html.

I really need help on that problem and I don't know how to fix it.

Thanks.


Solution

  • This is most likely an issue with the filters-1.0.0.js file not loading.

    If you're in Chrome, check your javascript console to see if there's a "not found" error. Also, check the source code to see if you can find "filters.js" or "filters-1.0.0.js" (this is what it should be after v1.09).