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
python django python-2.7 flask flask-appbuilder
add a comment |
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
python django python-2.7 flask flask-appbuilder
add a comment |
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
python django python-2.7 flask flask-appbuilder
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
python django python-2.7 flask flask-appbuilder
edited 17 hours ago
eandersson
18.2k66693
18.2k66693
asked 17 hours ago
Mark Krystal
97211
97211
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
draft saved
draft discarded
draft saved
draft discarded
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password