title: Flask Appbuilder Run Error: "IndexError: list index out of range"
body: <p>My views.py and models.py are as below:</p>
  
  <p><strong>views.py:</strong></p>
  
  <pre><code>import calendar
  from flask_appbuilder import ModelView
  from flask_appbuilder.models.sqla.interface import SQLAInterface
  from flask_appbuilder.charts.views import GroupByChartView
  from flask_appbuilder.models.group import aggregate_count
  from flask_appbuilder.widgets import FormHorizontalWidget, FormInlineWidget, FormVerticalWidget
  from flask_babel import lazy_gettext as _
  
  from app import db, appbuilder
  from .models import DB, Table
  
  class tableModelView(ModelView):
      datamodel = SQLAInterface(Table)
      list_columns = ['table_group.table_db_name', 'table_name', 'ddl']
      base_order = ['table_group.table_db_name', 'asc']
      show_fieldsets = [
              ('Summary', {'fields' : list_columns})
          ]
      add_fieldsets = [
              ('Summary', {'fields' : list_columns})
          ]
      edit_fieldsets = [
              ('Summary', {'fields' : list_columns})
          ]
  
  class GroupModelView(ModelView):
      datamodel = SQLAInterface(DB)
      related_views = [tableModelView]
  
  
  db.create_all()
  appbuilder.add_view(GroupModelView, "List DBs",
                      icon="fa-folder-open-o", category="DB", category_icon='fa-envelope')
  appbuilder.add_separator("Table")
  appbuilder.add_view(tableModelView, "List Tables",
                      icon="fa-folder-open-o", category="Table", category_icon='fa-envelope')
  </code></pre>
  
  <p><strong>models.py:</strong></p>
  
  <pre><code>import datetime
  from sqlalchemy import Column, Integer, String, ForeignKey, Date
  from sqlalchemy.orm import relationship
  from flask_appbuilder import Model
  
  mindate = datetime.date(datetime.MINYEAR, 1, 1)
  
  class DB(Model):
      db_name = Column(String(50), unique=True, primary_key=True, nullable=False)
  
      def __repr__(self):
          return self.name
  
  class Table(Model):
      table_name = Column(String(100), primary_key=True)
      ddl = Column(String(16384), unique=True)
  
      table_db_name = Column(Integer, ForeignKey(DB.db_name), nullable=False)
      table_group = relationship("DB")
  
      def __repr__(self):
          return self.name
  </code></pre>
  
  <p>However, when I run it, it has this error:  </p>
  
  <pre><code>Traceback (most recent call last):
    File "run.py", line 1, in &lt;module&gt;
      from app import app
    File "/Users/x0m00jk/Platform-Manager/app/__init__.py", line 28, in &lt;module&gt;
      from app import models, views
    File "/Users/x0m00jk/Platform-Manager/app/views.py", line 56, in &lt;module&gt;
      icon="fa-folder-open-o", category="DB", category_icon='fa-envelope')
    File "/usr/local/lib/python2.7/site-packages/flask_appbuilder/base.py", line 351, in add_view
      baseview = self._check_and_init(baseview)
    File "/usr/local/lib/python2.7/site-packages/flask_appbuilder/base.py", line 303, in _check_and_init
      baseview = baseview()
    File "/usr/local/lib/python2.7/site-packages/flask_appbuilder/views.py", line 451, in __init__
      super(ModelView, self).__init__(**kwargs)
    File "/usr/local/lib/python2.7/site-packages/flask_appbuilder/baseviews.py", line 631, in __init__
      super(BaseCRUDView, self).__init__(**kwargs)
    File "/usr/local/lib/python2.7/site-packages/flask_appbuilder/baseviews.py", line 398, in __init__
      self._init_properties()
    File "/usr/local/lib/python2.7/site-packages/flask_appbuilder/baseviews.py", line 696, in _init_properties
      self.list_columns = self.list_columns or [list_cols[0]]
  IndexError: list index out of range
  </code></pre>