Flask Appbuilder Run Error: “IndexError: list index out of range”











up vote
0
down vote

favorite












My views.py and models.py are as below:



views.py:



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')


models.py:



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


However, when I run it, it has this error:



Traceback (most recent call last):
File "run.py", line 1, in <module>
from app import app
File "/Users/x0m00jk/Platform-Manager/app/__init__.py", line 28, in <module>
from app import models, views
File "/Users/x0m00jk/Platform-Manager/app/views.py", line 56, in <module>
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









share|improve this question




























    up vote
    0
    down vote

    favorite












    My views.py and models.py are as below:



    views.py:



    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')


    models.py:



    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


    However, when I run it, it has this error:



    Traceback (most recent call last):
    File "run.py", line 1, in <module>
    from app import app
    File "/Users/x0m00jk/Platform-Manager/app/__init__.py", line 28, in <module>
    from app import models, views
    File "/Users/x0m00jk/Platform-Manager/app/views.py", line 56, in <module>
    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









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      My views.py and models.py are as below:



      views.py:



      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')


      models.py:



      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


      However, when I run it, it has this error:



      Traceback (most recent call last):
      File "run.py", line 1, in <module>
      from app import app
      File "/Users/x0m00jk/Platform-Manager/app/__init__.py", line 28, in <module>
      from app import models, views
      File "/Users/x0m00jk/Platform-Manager/app/views.py", line 56, in <module>
      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









      share|improve this question















      My views.py and models.py are as below:



      views.py:



      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')


      models.py:



      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


      However, when I run it, it has this error:



      Traceback (most recent call last):
      File "run.py", line 1, in <module>
      from app import app
      File "/Users/x0m00jk/Platform-Manager/app/__init__.py", line 28, in <module>
      from app import models, views
      File "/Users/x0m00jk/Platform-Manager/app/views.py", line 56, in <module>
      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






      python django python-2.7 flask flask-appbuilder






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 17 hours ago









      eandersson

      18.2k66693




      18.2k66693










      asked 17 hours ago









      Mark Krystal

      97211




      97211





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183923%2fflask-appbuilder-run-error-indexerror-list-index-out-of-range%23new-answer', 'question_page');
          }
          );

          Post as a guest





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183923%2fflask-appbuilder-run-error-indexerror-list-index-out-of-range%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          横浜市

          Rostock

          Europa