Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any options for admin panel? #167

Closed
bnopne opened this issue Mar 19, 2018 · 5 comments
Closed

Any options for admin panel? #167

bnopne opened this issue Mar 19, 2018 · 5 comments
Labels
question A community question, closed when inactive.

Comments

@bnopne
Copy link

bnopne commented Mar 19, 2018

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).

@fantix
Copy link
Member

fantix commented Mar 19, 2018

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.

@fantix fantix added the question A community question, closed when inactive. label Mar 19, 2018
@bnopne
Copy link
Author

bnopne commented Mar 21, 2018

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

@bnopne bnopne closed this as completed Mar 21, 2018
@fantix
Copy link
Member

fantix commented Mar 21, 2018

Quite welcome you are. 😸

@xnuinside
Copy link
Contributor

xnuinside commented May 1, 2020

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

@fantix
Copy link
Member

fantix commented May 2, 2020

@xnuinside thanks for using and sharing! This is now added on https://python-gino.org/credits/

refs #260, python-gino/python-gino.org@f45fe7f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A community question, closed when inactive.
Projects
None yet
Development

No branches or pull requests

3 participants