Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help3403


This forum is provided to promote discussion amongst students enrolled in Agile Web Development (CITS3403).
 
Options:
RSS cloud
Jump to:

flask-admin

1 of 419 articles shown, currently no other people reading this forum.
photo
From: Aiden L.
Date: Fri 22nd May 2020, 2:25pm
Actions: 
        Login-to-reply

 

Hi all, 

I'm currently trying to initialise and add views to my flask admin. I'm struggling with 
where to put the admin.add_view(modelview...).

I have the following code in my __init__.py;

app.config['FLASK_ADMIN_SWATCH'] = 'cerulean'
admin = Admin(app, name='GameFinder', template_mode='bootstrap3')

and cant figure out where to put;

admin.add_view(ModelView(User, db.session))
admin.add_view(ModelView(Post, db.session))
...

All the tutorials I can find online have their applications made from one file, so 
separating these while keeping the User and Post classes accessible and the admin object is 
proving difficult.

Any help or pointers in the right direction would be appreciated.
Cheers.

Related articles

Flask-Admin (all 3) RSS
├─ original   Mon 18th May 2020, 1:11pm, Kai B.
├─ THIS   Fri 22nd May 2020, 2:25pm, Aiden L.
└─ reply 2   Fri 22nd May 2020, 4:03pm, Aiden L.
This Page


Program written by: [email protected]
Feedback welcome
Last modified: 11:27am Sep 21 2020