Created
April 26, 2014 02:03
-
-
Save italomaia/11309843 to your computer and use it in GitHub Desktop.
Name collision using flask-admin and modelview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, Blueprint | |
from flask.ext.admin import Admin | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from flask.ext.admin.contrib.sqla import ModelView | |
app = Flask(__name__) | |
app.debug = True | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' | |
db = SQLAlchemy(app) | |
wiki = Blueprint('wiki', __name__) | |
app.register_blueprint(wiki) | |
class Wiki(db.Model): | |
id = db.Column(db.Integer, primary_key=True) | |
title = db.Column(db.String(100), unique=True) | |
content = db.Column(db.Text) | |
db.create_all() | |
admin = Admin(app) | |
admin.add_view(ModelView(Wiki, db.session)) | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment