-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathadmin.py
More file actions
19 lines (15 loc) · 758 Bytes
/
admin.py
File metadata and controls
19 lines (15 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os
from flask_admin import Admin
from .models import db, User, Food, Accessories, Pet
from flask_admin.contrib.sqla import ModelView
def setup_admin(app):
app.secret_key = os.environ.get('FLASK_APP_KEY', 'sample key')
app.config['FLASK_ADMIN_SWATCH'] = 'cerulean'
admin = Admin(app, name='4Geeks Admin', template_mode='bootstrap3')
# Add your models here, for example this is how we add a the User model to the admin
admin.add_view(ModelView(User, db.session))
admin.add_view(ModelView(Food, db.session))
admin.add_view(ModelView(Accessories, db.session))
admin.add_view(ModelView(Pet, db.session))
# You can duplicate that line to add mew models
# admin.add_view(ModelView(YourModelName, db.session))