Module provides classes for rendering views for SQLAlchemy based models.
Note
The following packages must be installed:
Bases: flask_velox.mixins.sqla.read.ListModelMixin, flask_velox.mixins.context.ContextMixin, flask_velox.mixins.template.TemplateMixin
Handles rendering templates which list out model objects.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.velox.views.sqla.model import ModelListView
from yourapp.models import SomeModel
app = Flask(__name__)
db = SQLAlchemy(app)
class MyListView(ModelListView):
template = 'templates/list.html'
session = db.session
model = SomeModel
app.add_url_rule('/', view_func=MyListView.as_view('list'))
app.run()
|
Bases: flask_velox.mixins.sqla.read.ObjectMixin, flask_velox.mixins.template.TemplateMixin
View for rendering a single SQLALchemy object within a template.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.velox.views.sqla.read import ObjectView
from yourapp.models import SomeModel
app = Flask(__name__)
db = SQLAlchemy(app)
class MyObjectView(ObjectView):
template = 'templates/object.html'
session = db.session
model = SomeModel
app.add_url_rule('/', view_func=MyObjectView.as_view('object'))
app.run()
|
Bases: flask_velox.mixins.sqla.read.TableModelMixin, flask_velox.views.sqla.read.ModelListView
View renders model lists in a table extending ModelListView adding extra attributes to configure the table output.