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

Custom ModelView with column_searchable_list does not work #99

Open
ogun- opened this issue Feb 5, 2015 · 0 comments
Open

Custom ModelView with column_searchable_list does not work #99

ogun- opened this issue Feb 5, 2015 · 0 comments

Comments

@ogun-
Copy link

ogun- commented Feb 5, 2015

I registered a custom ModelView to my CompanyModel

from sandman import app
from sandman.model import register, Model, activate
from flask.ext.admin.contrib.sqla import ModelView

class CompanyView(ModelView):
    column_searchable_list = ('name',)
    column_list = ('name',)

class Company(Model):
    __tablename__ = 'company'
    __endpoint__ = 'Company'
    __view__ = CompanyView

This throws an exception:

  File "/usr/local/lib/python2.7/dist-packages/Flask_Admin-1.0.8-py2.7.egg/flask_admin/model/base.py", line 540, in _refresh_cache
    self._search_supported = self.init_search()
  File "/usr/local/lib/python2.7/dist-packages/Flask_Admin-1.0.8-py2.7.egg/flask_admin/contrib/sqla/view.py", line 414, in init_search
    'Failed to setup search for "%s"' % p)
Exception: Can only search on text columns. Failed to setup search for "name"

The problem seems to be that sqlalchemy (0.9.8) reflection inspector detects String Columns (as defined in my model) as VARCHAR Columns. This does not match any of flask-admins allowed text column types:

def is_text_column_type(self, name):
    ...
    return name in ('string', 'unicode', 'text', 'unicodetext')
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

No branches or pull requests

1 participant