Skip to content

Optionnal endpoint namespace support#120

Open
noirbizarre wants to merge 2 commits intosyrusakbary:masterfrom
noirbizarre:namespace
Open

Optionnal endpoint namespace support#120
noirbizarre wants to merge 2 commits intosyrusakbary:masterfrom
noirbizarre:namespace

Conversation

@noirbizarre
Copy link
Contributor

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 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant