I am really new to Flask and Flask-Admin.
My goal is simply to delete the possibility of the user accessing the "list" view for a certain model. I'm sure there must be some easy way of doing this, as there is one for editing, creating and so on, but I just can't find it.
I tried adding list to "disallowed actions" but (as expected) that didn't work as "list" is not actually an action. Also tried several ways of attacking that view (assigning empty form, assigning empty template, and other futile undertakings).
What I need is to the user to go straight to the "create" tab (which is the only one available for the model) when clicking on the top nav bar.
Thank you.
SOLUTION based on @charlemagne
@expose('/')
def index(self):
return redirect(url_for('newpatient.create_view'))
As the list view is the default view rendered for the '/' url, this redirects the user to the creation view, even when clicking again on "list" making the list view effectively inaccessible.
Since the list view is the index view, and you need to have an index view, you can not simply disable it.
What you can do instead is overwrite the index
method of your view, and route it to a different endpoint instead, for example the edit_view
.
You can also check for the endpoint in is_accessible
, but this would lead to the user being routed to the now inaccessible list view when trying to access the model over a menu.