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

3 of 419 articles shown, currently no other people reading this forum.
photo
From: Kai B.
Date: Mon 18th May, 1:11pm
Actions: 
        Login-to-reply
Hey guys,
I'm really struggling to use flask_admin at the moment. I am trying to set up a 
dashboard that displays some kind of "job board" where an admin can click on one 
item to submit a response to user (where the user has submitted an answer to a 
question). I've looked through the documentation a few times but I just can't wrap 
my head around anything. I'd like the dashboard to just appear on the basic /admin 
route, but I also dont know how to allow this route to take multiple (or even one) 
of the database models

I have flask_admin set up at the moment to just do the usual CRUD operations on the 
database using admin.add_view(...), but editing quizzes through here obviously 
doesn't look great and has too many options for simply responding to an answer.

I'm pretty sure what I need to know is how to properly use @expose() within 
different views, but I can't seem to do what I want so I may need more info.

Thanks for any help

Kai

Flask-Admin

photo
From: Aiden L.
Date: Fri 22nd May, 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.

Flask-Admin

photo
From: Aiden L.
Date: Fri 22nd May, 4:03pm
Actions: 
        Login-to-reply
If anyone is struggling to do the same, I solved this by importing the already made classes at the 
bottom of __init__.py;

ie. 

##initialisation code above##

from flask_admin.contrib.sqla import ModelView
from app.models import User, Post

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


Program written by: [email protected]
Feedback welcome
Last modified:  8:27am May 24 2020