Using Flask-SuperAdmin, I've been having a lot of url name collision with automatic endpoint creation for ModelAdmin.
To avoid collision, I wanted to prefix all URLs names with admin. and keep the index view at root.
This PR is doing that. It does not modify the default behavior but allow to easily prefix all admin views endpoints with a common prefix so I can write this:
admin = Admin(app, namespace='admin')
admin.add_view(MyView(endpoint='testadmin'))
admin.add_view(MyView())
admin.register(User)
url_for('admin.index') # The IndexView is in the namespace root
url_for('admin.testadmin.index')
url_for('admin.myview.index')
url_for('admin.user.list')
This way I can keep the user.list url name for the non-admin view without manually specifying an endpoint for each view.
I'm ready to discuss this choice and the other alternatives you can offer.
(I also renamed the setup() into setup_admin() in test_model.py because it was call twice).
Hi!
Using Flask-SuperAdmin, I've been having a lot of url name collision with automatic endpoint creation for
ModelAdmin
. To avoid collision, I wanted to prefix all URLs names withadmin.
and keep the index view at root.This PR is doing that. It does not modify the default behavior but allow to easily prefix all admin views endpoints with a common prefix so I can write this:
This way I can keep the
user.list
url name for the non-admin view without manually specifying an endpoint for each view.I'm ready to discuss this choice and the other alternatives you can offer.
(I also renamed the
setup()
intosetup_admin()
intest_model.py
because it was call twice).