How to reference a ModelView in flask-admin

Viewed 7424

What's the right way to get the URL for a flask-admin ModelView?

Here's a very simple example:

my_admin_view.py

from flask.ext.admin.contrib.sqla import ModelView
from common.flask_app import app
from models import db, User, Role

admin = Admin(app, name="Boost Admin")

admin.add_view(ModelView(User,  db.session, category="model"))
admin.add_view(ModelView(Role,  db.session, category="model"))

my_admin_template.html

...
<p>Check out my user admin link:</p>

<a href="{{ url_for('modelview.user') }}">User view link</a>
{#                   ______________ 
                     what argument to pass in here??      #}
...

What's the correct argument to pass to url_for(...)?

I've tried modelview.user, my_admin_view.modelview.user, etc. None of them seem to resolve correctly, and I'd like to avoid hardcoding the link.

thanks!

3 Answers
Related