This code recipe gives the idea of what you have to use Flask-admin with PostgreSQL database.
From flask import flaskfrom flask.ext.admin import adminfrom flask.ext.admin import baseviewfrom flask.ext.admin import ex Posefrom flask.ext.sqlalchemy Import sqlalchemyfrom flask.ext.admin.contrib.sqla Import Modelviewapp = Flask (__name__) app.config[' secret_key ' = ' 123456790 ' app.config[' sqlalchemy_database_uri '] = ' postgresql://postgres:[email Protected]/scrapy ' db = SQLAlchemy (APP) admin = admin (APP) class MyView (Baseview): @expose ('/') def index (self) : return Self.render (' index.html ') class Cars (db. Model): can_create = False id = db. Column (db. Integer, primary_key=true) name = db. Column (db. String () Price = db. Column (db. String (+)) Admin.add_view (MyView (name= ' Hello ')) Admin.add_view (Modelview (Cars, db.session)) if __name__ = = ' __ Main__ ': app.run (host= ' 0.0.0.0 ', port=8080,debug=true)
[Python] Use Flask-admin with PostgreSQL