Gino: Any options for admin panel?

Created on 19 Mar 2018  路  5Comments  路  Source: python-gino/gino

Are there any options of auto-generated admin panel for gino models? I tried to use gino models on Flask-admin, but had no luck with it (_sa_instance_state_manager attribute was missing).

question

All 5 comments

Oh yes, we used Flask-Admin in one of our project with GINO. The trick is to replace gino.Gino with flask_sqlalchemy.SQLAlchemy, thanks to duck typing. Here's the code:

import os

if os.environ.get('FLASK_APP')
    from flask_sqlalchemy import SQLAlchemy
    db = SQLAlchemy()
else:
    from gino.ext.sanic import Gino
    db = Gino()


def init_app(app):
    from . import accounting, deposit, product, timeline, user

    db.init_app(app)

As you can see, I used environment variable FLASK_APP to find out if current process is a Flask-Admin server or a Sanic API server. You can replace it with whatever suits you. Then you can use ModelView of Flask-Admin to make it work. However this is very hacky and may break at any time, please be noted. Good luck!

Also I'm planning to build such a admin console with GINO, GraphQL and Vue.js. But that is a long story.

Thanks a lot, Dear Sir, may The Force be with you!

Quite welcome you are. 馃樃

Maybe will be useful for someone: https://github.com/xnuinside/gino_admin . It's in active development now, but CRUD & upload from csv already works

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AmatanHead picture AmatanHead  路  5Comments

pmillssf picture pmillssf  路  3Comments

retnikt picture retnikt  路  6Comments

ape364 picture ape364  路  6Comments

saeedghx68 picture saeedghx68  路  6Comments